hello friends…
I have workflow that waiting to receive a signal
the problem was history_node table rows always inserted til signal received …
I already set my RD to 1 day … but its not clear because worker still running …
any solution like clear all history with specific run ID and status complete ?
the problem was history_node table rows always inserted til signal received …
How are you waiting for the signal? You shouldn’t use busy looping to wait.
thanks for replying ,
yes, i use looping to checking if signal was send…
when receive break the loop and run activity …
is there any other way to checking if signal was send ?
Yes, use signal Channel.Receive which blocks until there is a message in the channel. You can use a Selector to wait for multiple Channels.
its solved as your suggested …
but its still creating like 5 logs or 5 rows in history node for a minute … in every workflow run …
well before was created like 32 logs/rows for a minute to wait for signal now its better …
thank you very very much …
Would you post your workflow code? It looks like you are still doing busy waiting.
well now I use code like below :
//signal receiver
selector := workflow.NewSelector(ctx)
selectorCh := workflow.GetSignalChannel(ctx, ID)
selector.AddReceive(selectorCh, func(ch workflow.ReceiveChannel, _ bool) {
var signalStatus bool
ch.Receive(ctx, &signalStatus)
//run activity, signal was received
})
//duration for waiting signal
newDuration := req.Times.Sub(workflow.Now(ctx).Local())
timerFuture := workflow.NewTimer(ctx, newDuration)
selector.AddFuture(timerFuture, func(f workflow.Future) {
//if till duration time out and time signal still not get
//run activity
})
ctx = actvityOption(ctx, req)
selector.Select(ctx)
The code looks OK. Could you post an example of “5 logs or 5 rows in history node for a minute … in every workflow run …”?
with code above it was created 9 history till duration timeout, timeout duration was a minute.
even if timeout duration increase it to an hour , history log still persist created 9 history in db
and here json history in UI temporal history :
{
"events": [
{
"eventId": "1",
"eventTime": "2021-12-02T03:12:35.000Z",
"eventType": "WorkflowExecutionStarted",
"version": "0",
"taskId": "5283829",
"workflowExecutionStartedEventAttributes": {
"workflowType": {
"name": "GeneralWorkflow"
},
"parentWorkflowNamespace": "",
"parentInitiatedEventId": "0",
"taskQueue": {
"name": "GeneralWorkflow",
"kind": "Normal"
},
"input": {
"payloads": [
{
"metadata": {
"encoding": "anNvbi9wbGFpbg=="
},
"data": "eyJJRCI6IjMzOWY5ZjE2LWI4ZDYtNDExYS1iZmU3LWI4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0="
}
]
},
"workflowExecutionTimeout": "0s",
"workflowRunTimeout": "0s",
"workflowTaskTimeout": "10s",
"continuedExecutionRunId": "",
"initiator": "Unspecified",
"originalExecutionRunId": "47ddae00-27ce-4f04-bd58-321e0c79b75a",
"identity": "471314@widiloyalto-Lenovo-ThinkBook-14-IML@",
"firstExecutionRunId": "47ddae00-27ce-4f04-bd58-321e0c79b75a",
"attempt": 1,
"cronSchedule": "",
"firstWorkflowTaskBackoff": "0s",
"header": {
"fields": {}
}
}
},
{
"eventId": "2",
"eventTime": "2021-12-02T03:12:35.000Z",
"eventType": "WorkflowTaskScheduled",
"version": "0",
"taskId": "5283830",
"workflowTaskScheduledEventAttributes": {
"taskQueue": {
"name": "GeneralWorkflow",
"kind": "Normal"
},
"startToCloseTimeout": "10s",
"attempt": 1
}
},
{
"eventId": "3",
"eventTime": "2021-12-02T03:12:35.000Z",
"eventType": "WorkflowTaskStarted",
"version": "0",
"taskId": "5283834",
"workflowTaskStartedEventAttributes": {
"scheduledEventId": "2",
"identity": "471842@widiloyalto-Lenovo-ThinkBook-14-IML@",
"requestId": "eaac3af7-b885-4195-aad2-b64391eb5b30"
}
},
{
"eventId": "4",
"eventTime": "2021-12-02T03:12:35.000Z",
"eventType": "WorkflowTaskCompleted",
"version": "0",
"taskId": "5283837",
"workflowTaskCompletedEventAttributes": {
"scheduledEventId": "2",
"startedEventId": "3",
"identity": "471842@widiloyalto-Lenovo-ThinkBook-14-IML@",
"binaryChecksum": "517131e438d90c96ed5b2f074e71ddee"
}
},
{
"eventId": "5",
"eventTime": "2021-12-02T03:12:35.000Z",
"eventType": "TimerStarted",
"version": "0",
"taskId": "5283838",
"timerStartedEventAttributes": {
"timerId": "5",
"startToFireTimeout": "59s",
"workflowTaskCompletedEventId": "4"
}
},
{
"eventId": "6",
"eventTime": "2021-12-02T03:13:35.000Z",
"eventType": "TimerFired",
"version": "0",
"taskId": "5283841",
"timerFiredEventAttributes": {
"timerId": "5",
"startedEventId": "5"
}
},
{
"eventId": "7",
"eventTime": "2021-12-02T03:13:35.000Z",
"eventType": "WorkflowTaskScheduled",
"version": "0",
"taskId": "5283842",
"workflowTaskScheduledEventAttributes": {
"taskQueue": {
"name": "widiloyalto-Lenovo-ThinkBook-14-IML:ef80082a-35f6-4b08-9c98-b622c1eb7bda",
"kind": "Sticky"
},
"startToCloseTimeout": "10s",
"attempt": 1
}
},
{
"eventId": "8",
"eventTime": "2021-12-02T03:13:35.000Z",
"eventType": "WorkflowTaskStarted",
"version": "0",
"taskId": "5283846",
"workflowTaskStartedEventAttributes": {
"scheduledEventId": "7",
"identity": "471842@widiloyalto-Lenovo-ThinkBook-14-IML@",
"requestId": "8380a0eb-7111-45bd-804d-657e5f64bbd8"
}
},
{
"eventId": "9",
"eventTime": "2021-12-02T03:13:35.000Z",
"eventType": "WorkflowTaskCompleted",
"version": "0",
"taskId": "5283849",
"workflowTaskCompletedEventAttributes": {
"scheduledEventId": "7",
"startedEventId": "8",
"identity": "471842@widiloyalto-Lenovo-ThinkBook-14-IML@",
"binaryChecksum": "517131e438d90c96ed5b2f074e71ddee"
}
},
{
"eventId": "10",
"eventTime": "2021-12-02T03:13:35.000Z",
"eventType": "ActivityTaskScheduled",
"version": "0",
"taskId": "5283850",
"activityTaskScheduledEventAttributes": {
"activityId": "10",
"activityType": {
"name": "GeneralActivities"
},
"namespace": "",
"taskQueue": {
"name": "GeneralWorkflow",
"kind": "Normal"
},
"header": {
"fields": {}
},
"input": {
"payloads": [
{
"metadata": {
"encoding": "anNvbi9wbGFpbg=="
},
"data": "eyJJRCI6IjMzOWY5ZjE2LWI4ZDYtNDExYS1iZmU3LWI4Mzc5NWJkNTRjOCIsIkFjY2Vzc1Rva2VuIjoiZXlKaGJHY2lPaUpJVXpJMU5pSXNJblI1Y0NJNklrcFhWQ0o5LmV5SjFkV2xrSWpvaVkyWTRaamhsWW1RdFltWTFNQzAwTXpaa0xUbG1ObUl0WWpRMU9UYzBNekkzTVdNMUlpd2liV1Z0WW1WeVgybGtJam9pWm1WbE9UQTBNbU10TTJVNFpDMDBZV0ZoTFRsbVl6QXRaV1k1TnpKaU1ESm1NRGhqSWl3aVpYaHdJam94TmpNNE5ERTVOekEyTENKcGMzTWlPaUpoZFhSb0luMC5kTzBoRE5TSkJtQXdGb1g3enhYV3NpTXJ2LXp0ekd6elBmZm9tTXMxNHY4IiwiVGltZXMiOiIyMDIxLTEyLTAyVDEwOjEzOjM1LjExNzY1ODM2KzA3OjAwIiwiVHlwZXNUaW1lcyI6ImFmdGVyIiwiVGFzayI6Imh0dHA6Ly9sb2NhbGhvc3Q6ODA4MC91cGRhdGVzL3BheW1lbnRzL3twYXltZW50X2lkfS97bWVtYmVyX2lkfSIsIlRhc2tUeXBlIjoiaHR0cCIsIkRhdGEiOnsibWVtYmVyX2lkIjoiZmVlOTA0MmMtM2U4ZC00YWFhLTlmYzAtZWY5NzJiMDJmMDhjIiwicGF5bWVudF9pZCI6IjMzOWY5ZjE2LWI4ZDYtNDExYS1iZmU3LWI4Mzc5NWJkNTRjOCIsInN0YXR1c19wYXltZW50IjoiZmFpbGVkIn0sIk1ldGhvZCI6InBhdGNoIiwiV29ya2Zsb3dOYW1lIjoiR2VuZXJhbFdvcmtmbG93IiwiQXR0ZW1wdCI6MywiQ3JlYXRlU2lnbmFsIjpmYWxzZSwiU2lnbmFsU3RhdHVzIjpmYWxzZSwiUmV0cnlBdHRlbXAiOjMsIk1pbnV0ZVdhaXRUb1JldHJ5IjoxLCJDcm9uSm9iVHlwZSI6IiIsIkludGVydmFsIjoxMDAwMDAwMDAwLCJNYXhJbnRlcnZhbCI6MzAwMDAwMDAwMDAwfQ=="
}
]
},
"scheduleToCloseTimeout": "0s",
"scheduleToStartTimeout": "86400s",
"startToCloseTimeout": "86400s",
"heartbeatTimeout": "5s",
"workflowTaskCompletedEventId": "9",
"retryPolicy": {
"nonRetryableErrorTypes": [
"BusinessError"
],
"initialInterval": "1s",
"backoffCoefficient": 2,
"maximumInterval": "300s",
"maximumAttempts": 3
}
}
},
{
"eventId": "11",
"eventTime": "2021-12-02T03:13:35.000Z",
"eventType": "ActivityTaskStarted",
"version": "0",
"taskId": "5283855",
"activityTaskStartedEventAttributes": {
"scheduledEventId": "10",
"identity": "471842@widiloyalto-Lenovo-ThinkBook-14-IML@",
"requestId": "5fd4a1a2-4871-49ff-874a-60fbcaa1193b",
"attempt": 1
}
},
{
"eventId": "12",
"eventTime": "2021-12-02T03:13:35.000Z",
"eventType": "ActivityTaskCompleted",
"version": "0",
"taskId": "5283856",
"activityTaskCompletedEventAttributes": {
"result": {
"payloads": [
{
"metadata": {
"encoding": "anNvbi9wbGFpbg=="
},
"data": "eyJkYXRhIjoiUHJvY2VzcyBQYXltZW50IDogZmFpbGVkIiwibWV0YSI6eyJjb2RlIjoyMDAsImVycm9yIjpudWxsLCJtZXNzYWdlIjoiT0sifX0="
}
]
},
"scheduledEventId": "10",
"startedEventId": "11",
"identity": "471842@widiloyalto-Lenovo-ThinkBook-14-IML@"
}
},
{
"eventId": "13",
"eventTime": "2021-12-02T03:13:35.000Z",
"eventType": "WorkflowTaskScheduled",
"version": "0",
"taskId": "5283857",
"workflowTaskScheduledEventAttributes": {
"taskQueue": {
"name": "widiloyalto-Lenovo-ThinkBook-14-IML:ef80082a-35f6-4b08-9c98-b622c1eb7bda",
"kind": "Sticky"
},
"startToCloseTimeout": "10s",
"attempt": 1
}
},
{
"eventId": "14",
"eventTime": "2021-12-02T03:13:35.000Z",
"eventType": "WorkflowTaskStarted",
"version": "0",
"taskId": "5283861",
"workflowTaskStartedEventAttributes": {
"scheduledEventId": "13",
"identity": "471842@widiloyalto-Lenovo-ThinkBook-14-IML@",
"requestId": "afdf370e-eeee-49a7-ae88-392c76617e26"
}
},
{
"eventId": "15",
"eventTime": "2021-12-02T03:13:35.000Z",
"eventType": "WorkflowTaskCompleted",
"version": "0",
"taskId": "5283864",
"workflowTaskCompletedEventAttributes": {
"scheduledEventId": "13",
"startedEventId": "14",
"identity": "471842@widiloyalto-Lenovo-ThinkBook-14-IML@",
"binaryChecksum": "517131e438d90c96ed5b2f074e71ddee"
}
},
{
"eventId": "16",
"eventTime": "2021-12-02T03:13:35.000Z",
"eventType": "WorkflowExecutionCompleted",
"version": "0",
"taskId": "5283865",
"workflowExecutionCompletedEventAttributes": {
"result": {
"payloads": [
{
"metadata": {
"encoding": "anNvbi9wbGFpbg=="
},
"data": "eyJkYXRhIjoiUHJvY2VzcyBQYXltZW50IDogZmFpbGVkIiwibWV0YSI6eyJjb2RlIjoyMDAsImVycm9yIjpudWxsLCJtZXNzYWdlIjoiT0sifX0="
}
]
},
"workflowTaskCompletedEventId": "15",
"newExecutionRunId": ""
}
}
]
}
I think I misunderstood your previous message. The history you posted looks absolutely normal and is not going to grow with time, only with actions that your workflow takes.