@@ -52,7 +52,7 @@ const (
52
52
53
53
noRetryBackoff = time .Duration (- 1 )
54
54
55
- historySizeEstimationOffset = 100 * 1024
55
+ historySizeEstimationOffset = 1 * 1024
56
56
)
57
57
58
58
type (
@@ -305,12 +305,13 @@ func (eh *history) verifyAllEventsProcessed() error {
305
305
}
306
306
307
307
func (eh * history ) nextDecisionEvents () (nextEvents []* s.HistoryEvent , markers []* s.HistoryEvent , historySizeEstimation int , err error ) {
308
+ historySizeEstimation = estimateHistorySize (eh .loadedEvents )
308
309
if eh .currentIndex == len (eh .loadedEvents ) && ! eh .hasMoreEvents () {
309
310
eh .eventsHandler .logger .Info ("Returning 0 for historySizeEstimation" )
310
311
if err := eh .verifyAllEventsProcessed (); err != nil {
311
- return nil , nil , 0 , err
312
+ return nil , nil , historySizeEstimation , err
312
313
}
313
- return []* s.HistoryEvent {}, []* s.HistoryEvent {}, 0 , nil
314
+ return []* s.HistoryEvent {}, []* s.HistoryEvent {}, historySizeEstimation , nil
314
315
}
315
316
316
317
// Process events
@@ -375,6 +376,8 @@ OrderEvents:
375
376
historySizeEstimation += estimateHistorySize (nextEvents )
376
377
historySizeEstimation += estimateHistorySize (markers )
377
378
379
+ eh .eventsHandler .logger .Info (fmt .Sprintf ("Returning historySizeEstimation not zero of %d" , historySizeEstimation ))
380
+
378
381
return nextEvents , markers , historySizeEstimation , nil
379
382
}
380
383
@@ -477,9 +480,6 @@ func estimateHistorySize(events []*s.HistoryEvent) int {
477
480
sum += len (e .SignalExternalWorkflowExecutionInitiatedEventAttributes .Control )
478
481
sum += len (e .SignalExternalWorkflowExecutionInitiatedEventAttributes .Input )
479
482
}
480
- default :
481
- // ignore other events
482
-
483
483
}
484
484
}
485
485
sum += historySizeEstimationOffset
@@ -1012,14 +1012,12 @@ ProcessEvents:
1012
1012
return nil , err
1013
1013
}
1014
1014
1015
- if isLast {
1016
- w .workflowInfo .TotalHistoryBytes += int64 (historySizeEstimation )
1017
- w .wth .logger .Info ("DIfferences between history size estimation and actual size" ,
1018
- zap .Int ("HistoryEstimation" , historySizeEstimation ),
1019
- zap .Int64 ("HistorySizeEstimation" , w .workflowInfo .TotalHistoryBytes ),
1020
- zap .Int64 ("ActualHistorySize" , w .workflowInfo .HistoryBytesServer ),
1021
- zap .Int64 ("HistorySizeDiff" , w .workflowInfo .TotalHistoryBytes - w .workflowInfo .HistoryBytesServer ))
1022
- }
1015
+ w .workflowInfo .TotalHistoryBytes += int64 (historySizeEstimation )
1016
+ w .wth .logger .Info ("DIfferences between history size estimation and actual size" ,
1017
+ zap .Int ("HistoryEstimation" , historySizeEstimation ),
1018
+ zap .Int64 ("HistorySizeEstimation" , w .workflowInfo .TotalHistoryBytes ),
1019
+ zap .Int64 ("ActualHistorySize" , w .workflowInfo .HistoryBytesServer ),
1020
+ zap .Int64 ("HistorySizeDiff" , w .workflowInfo .TotalHistoryBytes - w .workflowInfo .HistoryBytesServer ))
1023
1021
1024
1022
err = eventHandler .ProcessEvent (event , isInReplay , isLast )
1025
1023
if err != nil {
0 commit comments