# Optimize history records for a workflow with all local activities

**URL:** <https://community.temporal.io/t/optimize-history-records-for-a-workflow-with-all-local-activities/2819>\
**Category:** Community Support\
**Tags:** java-sdk, cassandra\
**Created:** [August 27, 2021, 9:38pm UTC](https://community.temporal.io/t/optimize-history-records-for-a-workflow-with-all-local-activities/2819 "2021-08-27T21:38:24Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![ramyamagham](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/ramyamagham/32/1125_2.png) [@ramyamagham](https://community.temporal.io/u/ramyamagham)\
**Post date:** [August 27, 2021, 9:38pm UTC](https://community.temporal.io/t/optimize-history-records-for-a-workflow-with-all-local-activities/2819/1 "2021-08-27T21:38:24Z")

</div>

Hi, I have two different workflows with one having 5 local activities and the other workflow with 10 local activities. When I browse through the history of each workflow on the UI, it shows the history entry as expected such as in the below screenshot.  
Wondering if there is any option to turn off and avoid the history writes to Cassandra as these are local activities and we don’t wait or retry more than 5 seconds for a workflow. This way maybe the size and writes can be saved? Currently within a 8 hour period the size of the history\_node table is reaching 2 TB at 800 workflows/sec.

 ![image](https://us1.discourse-cdn.com/flex016/uploads/temporal/original/2X/1/11bc88ea7991171027382b4c41ccf3bbc55276a3.png)

---

<div class="post-metadata">

**Author:** ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)\
**Post date:** [August 27, 2021, 9:49pm UTC](https://community.temporal.io/t/optimize-history-records-for-a-workflow-with-all-local-activities/2819/2 "2021-08-27T21:49:05Z")

</div>

Local activities have to be recorded as they are not reexecuted on replay. One possible optimization is to not include arguments into the marker event as they are there only for human consumption.

Set `LocalActivityOptions.doNotIncludeArgumentsIntoMarker` to `true` to not include them.

---

<div class="post-metadata">

**Author:** ![ramyamagham](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/ramyamagham/32/1125_2.png) [@ramyamagham](https://community.temporal.io/u/ramyamagham)\
**Post date:** [August 28, 2021, 3:57am UTC](https://community.temporal.io/t/optimize-history-records-for-a-workflow-with-all-local-activities/2819/3 "2021-08-28T03:57:22Z")

</div>

Thank you, we will try this option.  
Can you also please clarify when will the entries in history\_node table get purged? I ran a 8 hour test starting yesterday 12 pm to 8 pm. The retention is 1 day (minimum available), and we expected the data storage to start going down today 12 pm, but not much changed . We also reduced the gc grace seconds on that table to 3 hours. Can you please confirm if our understanding is right?

Also, how are the deletes issued to history\_node table? Do you mark the record with TTL or do you issue a delete command to Cassandra?

---

<div class="post-metadata">

**Author:** ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)\
**Post date:** [August 28, 2021, 4:38pm UTC](https://community.temporal.io/t/optimize-history-records-for-a-workflow-with-all-local-activities/2819/4 "2021-08-28T16:38:41Z")

</div>

The history\_node and other workflow data are purged after the retention period. The retention period for a workflow starts when it is closed.

> We also reduced the gc grace seconds on that table to 3 hours. Can you please confirm if our understanding is right?

I think it is a very bad idea to reduce the `gc grace seconds`. It will lead to the appearance of zombie records and potentially corrupt data.

Try running manual compaction instead.

---

<div class="post-metadata">

**Author:** ![ramyamagham](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/ramyamagham/32/1125_2.png) [@ramyamagham](https://community.temporal.io/u/ramyamagham)\
**Post date:** [August 31, 2021, 7:57pm UTC](https://community.temporal.io/t/optimize-history-records-for-a-workflow-with-all-local-activities/2819/5 "2021-08-31T19:57:23Z")

</div>

Thanks @maxim this is helpful. Also I am trying to change the retention period for a namespace that already exists, but I cannot find documentation or figure out how to change the retention period just for a given namespace using the Java SDK.

`NamespaceConfig nsConfig = UpdateNamespaceRequest.newBuilder().getConfigBuilder().setWorkflowExecutionRetentionTtl(Duration.newBuilder().setSeconds(86400).build()).build();`

Also none of the workflow options or other setup seems to be taking namespace config as an input.

Deprecate does not delete the namespace so that we can freshly create the namespace again with the chosen retention period:

```auto
WorkflowServiceStubs workflowService = WorkflowServiceStubs.newInstance(workflowServiceStubsOptions);
DeprecateNamespaceRequest deleteRequest = DeprecateNamespaceRequest.newBuilder().setName(NAMESPACE).build();
workflowService.futureStub().deprecateNamespace(deleteRequest);

```

---

<div class="post-metadata">

**Author:** ![tihomir](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tihomir/32/6580_2.png) [@tihomir](https://community.temporal.io/u/tihomir)\
**Post date:** [August 31, 2021, 8:27pm UTC](https://community.temporal.io/t/optimize-history-records-for-a-workflow-with-all-local-activities/2819/6 "2021-08-31T20:27:46Z")

</div>

You can use tctl to update the retention period for an existing namespace, for example:

`tctl namespace update --retention 2`

where the retention period is set in days.

Namespace deletion is currently not supported, you can track [this issue](https://github.com/temporalio/temporal/issues/1679) for updates.

---

<div class="post-metadata">

**Author:** ![ramyamagham](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/ramyamagham/32/1125_2.png) [@ramyamagham](https://community.temporal.io/u/ramyamagham)\
**Post date:** [August 31, 2021, 9:32pm UTC](https://community.temporal.io/t/optimize-history-records-for-a-workflow-with-all-local-activities/2819/7 "2021-08-31T21:32:36Z")

</div>

This is running in our company K8s cluster and we do not have access to login to run tctl command. Is there a way to do this same from Java SDK? @tihomir  
Thanks.

---

<div class="post-metadata">

**Author:** ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)\
**Post date:** [August 31, 2021, 9:59pm UTC](https://community.temporal.io/t/optimize-history-records-for-a-workflow-with-all-local-activities/2819/8 "2021-08-31T21:59:55Z")

</div>

Yes, all the `tctl` commands are using the [same gRPC interface](https://github.com/temporalio/api/blob/760fa1278ece08707f05b8937cc0b9c4c926eb6c/temporal/api/workflowservice/v1/service.proto#L65).

---

<div class="post-metadata">

**Author:** ![ramyamagham](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/ramyamagham/32/1125_2.png) [@ramyamagham](https://community.temporal.io/u/ramyamagham)\
**Post date:** [August 31, 2021, 10:53pm UTC](https://community.temporal.io/t/optimize-history-records-for-a-workflow-with-all-local-activities/2819/9 "2021-08-31T22:53:40Z")

</div>

But I cannot port forward to my laptop and installation of tctl is blocked in our K8s cluster. Is there a way I can do the same through Java SDK please?

---

<div class="post-metadata">

**Author:** ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)\
**Post date:** [September 1, 2021, 12:29am UTC](https://community.temporal.io/t/optimize-history-records-for-a-workflow-with-all-local-activities/2819/10 "2021-09-01T00:29:49Z")

</div>

I mean you can call that command using Java gRPC client to temporal:

```java
WorkflowServiceStubs workflowService = WorkflowServiceStubs.newInstance(workflowServiceStubsOptions);
workflowService.blockingStub().updateNamespace(...);

```

---

<div class="post-metadata">

**Author:** ![tihomir](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tihomir/32/6580_2.png) [@tihomir](https://community.temporal.io/u/tihomir)\
**Post date:** [September 1, 2021, 3:06am UTC](https://community.temporal.io/t/optimize-history-records-for-a-workflow-with-all-local-activities/2819/11 "2021-09-01T03:06:05Z")

</div>

Here is a full example for record:

```auto
UpdateNamespaceRequest request =
        UpdateNamespaceRequest.newBuilder()
            .setNamespace(myNameSpace)
            .setConfig(
                NamespaceConfig.newBuilder().setWorkflowExecutionRetentionTtl(days).build())
            .build();

    UpdateNamespaceResponse response = service.blockingStub().updateNamespace(request);

```

where `myNameSpace` is a String name of the namespace you want to update (must set)  
and `days` is of type com.google.protobuf.Duration  
So to create it for like three days you can do:

```auto
com.google.protobuf.Duration days =
        com.google.protobuf.Duration.newBuilder().setSeconds(3 * 86400).build();

```

You can inspect the response to see that retention is set to 3 days and you can also use tctl after to see if it indeed has been set with

`tctl namespace desc`

---

<div class="post-metadata">

**Author:** ![ramyamagham](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/ramyamagham/32/1125_2.png) [@ramyamagham](https://community.temporal.io/u/ramyamagham)\
**Post date:** [September 1, 2021, 3:53am UTC](https://community.temporal.io/t/optimize-history-records-for-a-workflow-with-all-local-activities/2819/12 "2021-09-01T03:53:27Z")

</div>

Yes, I got it @tihomir that worked, appreciate your code snippet anyway.  
Also, to make use of the “doNotIncludeArgumentsIntoMarker” on LocalActivityOptions, I was earlier using 0.29.1 Java SDK but I upgraded that to 1.0.8 which seems to be the version when it was introduced. However I get this error:

```auto
Exception in thread "main" java.lang.NoSuchMethodError: 'void com.google.common.base.Preconditions.checkArgument(boolean, java.lang.String, char, java.lang.Object)'
	at io.grpc.Metadata$Key.validateName(Metadata.java:742)
	at io.grpc.Metadata$Key.<init>(Metadata.java:750)
	at io.grpc.Metadata$Key.<init>(Metadata.java:668)
	at io.grpc.Metadata$AsciiKey.<init>(Metadata.java:959)
	at io.grpc.Metadata$AsciiKey.<init>(Metadata.java:954)
	at io.grpc.Metadata$Key.of(Metadata.java:705)
	at io.grpc.Metadata$Key.of(Metadata.java:701)
	at io.temporal.serviceclient.WorkflowServiceStubsImpl.<clinit>(WorkflowServiceStubsImpl.java:51)

```

I see suggestions to upgrade guava but I see the version is already the latest in mvn dependencies:  
com.google.guava:guava:jar:30.1.1-jre:compile

I have tried java sdk 1.0.0, 1.0.8, 1.2.0 but 0.29.1 is the only one that’s working for me. Have you seen this issue?

The worker is running on Temporal server 1.9.2 version.

---

<div class="post-metadata">

**Author:** ![tihomir](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tihomir/32/6580_2.png) [@tihomir](https://community.temporal.io/u/tihomir)\
**Post date:** [September 1, 2021, 4:41am UTC](https://community.temporal.io/t/optimize-history-records-for-a-workflow-with-all-local-activities/2819/13 "2021-09-01T04:41:13Z")

</div>

@ramyamagham  
tried with SDK 1.2.0 and setting `setDoNotIncludeArgumentsIntoMarker` on `LocalActivityOptions`  
worked fine on Server versions:  
1.10.5  
and the just released 1.12.0

---

<div class="post-metadata">

**Author:** ![ramyamagham](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/ramyamagham/32/1125_2.png) [@ramyamagham](https://community.temporal.io/u/ramyamagham)\
**Post date:** [September 1, 2021, 5:04am UTC](https://community.temporal.io/t/optimize-history-records-for-a-workflow-with-all-local-activities/2819/14 "2021-09-01T05:04:25Z")

</div>

I don’t think the error I am getting is specifically related to the setting “setDoNotIncludeArgumentsIntoMarker”.  
The worker is not even starting up due to error in line  
`WorkflowServiceStubs workflowService = WorkflowServiceStubs.newInstance(workflowServiceStubsOptions);`  
Do I have to upgrade the temporal server to 1.10.5? Is our conclusion that it won’t work on 1.9.2?  
There’s no compatibility chart available here or on temporalio website: [Maven Central Repository Search](https://search.maven.org/artifact/io.temporal/temporal-sdk)

---

<div class="post-metadata">

**Author:** ![tihomir](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tihomir/32/6580_2.png) [@tihomir](https://community.temporal.io/u/tihomir)\
**Post date:** [September 1, 2021, 3:41pm UTC](https://community.temporal.io/t/optimize-history-records-for-a-workflow-with-all-local-activities/2819/15 "2021-09-01T15:41:13Z")

</div>

Tested with server version 1.9.2 and sdk version 1.2.0 and did not get the same problem. Maybe something else might be going on in your setup or workflows. I am testing just the UpdateNamespaceRequest and single activity execution.

---

<div class="post-metadata">

**Author:** ![ramyamagham](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/ramyamagham/32/1125_2.png) [@ramyamagham](https://community.temporal.io/u/ramyamagham)\
**Post date:** [September 1, 2021, 4:34pm UTC](https://community.temporal.io/t/optimize-history-records-for-a-workflow-with-all-local-activities/2819/16 "2021-09-01T16:34:46Z")

</div>

Thanks a lot for verifying that. I will check more on my end.  
Have a nice day!

---

<div class="post-metadata">

**Author:** ![ramyamagham](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/ramyamagham/32/1125_2.png) [@ramyamagham](https://community.temporal.io/u/ramyamagham)\
**Post date:** [September 1, 2021, 5:01pm UTC](https://community.temporal.io/t/optimize-history-records-for-a-workflow-with-all-local-activities/2819/17 "2021-09-01T17:01:23Z")

</div>

Just for the record if anybody else has the same issue, changing the guava to older version worked for us and excluding the one from Temporal SDK.

```auto
libraryDependencies += "com.google.guava" % "guava" % "20.0"

```

---

<div class="post-metadata">

**Author:** ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)\
**Post date:** [September 1, 2021, 6:03pm UTC](https://community.temporal.io/t/optimize-history-records-for-a-workflow-with-all-local-activities/2819/18 "2021-09-01T18:03:49Z")

</div>

Would you file an issue to get the guava updated in the Temporal SDK?

---

<div class="post-metadata">

**Author:** ![ramyamagham](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/ramyamagham/32/1125_2.png) [@ramyamagham](https://community.temporal.io/u/ramyamagham)\
**Post date:** [September 2, 2021, 2:05am UTC](https://community.temporal.io/t/optimize-history-records-for-a-workflow-with-all-local-activities/2819/19 "2021-09-02T02:05:11Z")

</div>

So Temporal SDK is already using the latest “30.1.1-jre” which is what confused me yesterday when I googled for the error which suggested to upgrade to latest guava.  
As @tihomir had verified it works for him, and from my application dependencies I could not find any conflicting jars or dependencies from other libraries. But I had to fall back to older version of guava 20.0.  
So given this, I am not going to file a ticket. But thanks a ton for actively responding on this thread!
