Skip to content

Commit 99460b2

Browse files
committed
some change in logic
1 parent aea7ba9 commit 99460b2

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

internal/internal_task_handlers.go

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const (
5252

5353
noRetryBackoff = time.Duration(-1)
5454

55-
historySizeEstimationOffset = 100 * 1024
55+
historySizeEstimationOffset = 1 * 1024
5656
)
5757

5858
type (
@@ -305,12 +305,13 @@ func (eh *history) verifyAllEventsProcessed() error {
305305
}
306306

307307
func (eh *history) nextDecisionEvents() (nextEvents []*s.HistoryEvent, markers []*s.HistoryEvent, historySizeEstimation int, err error) {
308+
historySizeEstimation = estimateHistorySize(eh.loadedEvents)
308309
if eh.currentIndex == len(eh.loadedEvents) && !eh.hasMoreEvents() {
309310
eh.eventsHandler.logger.Info("Returning 0 for historySizeEstimation")
310311
if err := eh.verifyAllEventsProcessed(); err != nil {
311-
return nil, nil, 0, err
312+
return nil, nil, historySizeEstimation, err
312313
}
313-
return []*s.HistoryEvent{}, []*s.HistoryEvent{}, 0, nil
314+
return []*s.HistoryEvent{}, []*s.HistoryEvent{}, historySizeEstimation, nil
314315
}
315316

316317
// Process events
@@ -375,6 +376,8 @@ OrderEvents:
375376
historySizeEstimation += estimateHistorySize(nextEvents)
376377
historySizeEstimation += estimateHistorySize(markers)
377378

379+
eh.eventsHandler.logger.Info(fmt.Sprintf("Returning historySizeEstimation not zero of %d", historySizeEstimation))
380+
378381
return nextEvents, markers, historySizeEstimation, nil
379382
}
380383

@@ -477,9 +480,6 @@ func estimateHistorySize(events []*s.HistoryEvent) int {
477480
sum += len(e.SignalExternalWorkflowExecutionInitiatedEventAttributes.Control)
478481
sum += len(e.SignalExternalWorkflowExecutionInitiatedEventAttributes.Input)
479482
}
480-
default:
481-
// ignore other events
482-
483483
}
484484
}
485485
sum += historySizeEstimationOffset
@@ -1012,14 +1012,12 @@ ProcessEvents:
10121012
return nil, err
10131013
}
10141014

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))
10231021

10241022
err = eventHandler.ProcessEvent(event, isInReplay, isLast)
10251023
if err != nil {

0 commit comments

Comments
 (0)