-
Notifications
You must be signed in to change notification settings - Fork 252
Introduce retry metadata to batch struct #1970
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
agarakan
merged 5 commits into
enable-multithreaded-logging-by-default
from
poison-pill
Jan 15, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6b231dc
introduce retry metadata to batch struct
agarakan 8521373
Remove unused reset method
agarakan 7244af8
add unit tests for retryMetadata
agarakan d2f21e1
fix lint
agarakan 0fd01a7
Remove lastError and update expiration check
agarakan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -63,11 +63,11 @@ func (s *sender) Send(batch *logEventBatch) { | |
| if len(batch.events) == 0 { | ||
| return | ||
| } | ||
|
|
||
| // Initialize start time before build() | ||
| batch.initializeStartTime() | ||
| input := batch.build() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Once we start to use the retry heap, we're going to have to think about storing the built input on the batch. |
||
| startTime := time.Now() | ||
|
|
||
| retryCountShort := 0 | ||
| retryCountLong := 0 | ||
| for { | ||
| output, err := s.service.PutLogEvents(input) | ||
| if err == nil { | ||
|
|
@@ -84,7 +84,7 @@ func (s *sender) Send(batch *logEventBatch) { | |
| } | ||
| } | ||
| batch.done() | ||
| s.logger.Debugf("Pusher published %v log events to group: %v stream: %v with size %v KB in %v.", len(batch.events), batch.Group, batch.Stream, batch.bufferedSize/1024, time.Since(startTime)) | ||
| s.logger.Debugf("Pusher published %v log events to group: %v stream: %v with size %v KB in %v.", len(batch.events), batch.Group, batch.Stream, batch.bufferedSize/1024, time.Since(batch.startTime)) | ||
| return | ||
| } | ||
|
|
||
|
|
@@ -110,27 +110,28 @@ func (s *sender) Send(batch *logEventBatch) { | |
| s.logger.Errorf("Aws error received when sending logs to %v/%v: %v", batch.Group, batch.Stream, awsErr) | ||
| } | ||
|
|
||
| // retry wait strategy depends on the type of error returned | ||
| var wait time.Duration | ||
| if chooseRetryWaitStrategy(err) == retryLong { | ||
| wait = retryWaitLong(retryCountLong) | ||
| retryCountLong++ | ||
| } else { | ||
| wait = retryWaitShort(retryCountShort) | ||
| retryCountShort++ | ||
| } | ||
| // Update retry metadata in the batch | ||
| batch.updateRetryMetadata(err) | ||
|
|
||
| if time.Since(startTime)+wait > s.RetryDuration() { | ||
| s.logger.Errorf("All %v retries to %v/%v failed for PutLogEvents, request dropped.", retryCountShort+retryCountLong-1, batch.Group, batch.Stream) | ||
| // Check if retry would exceed max duration | ||
| totalRetries := batch.retryCountShort + batch.retryCountLong - 1 | ||
| if batch.nextRetryTime.After(batch.startTime.Add(s.RetryDuration())) { | ||
| s.logger.Errorf("All %v retries to %v/%v failed for PutLogEvents, request dropped.", totalRetries, batch.Group, batch.Stream) | ||
| batch.updateState() | ||
| return | ||
| } | ||
|
|
||
| s.logger.Warnf("Retried %v time, going to sleep %v before retrying.", retryCountShort+retryCountLong-1, wait) | ||
| // Calculate wait time until next retry | ||
| wait := time.Until(batch.nextRetryTime) | ||
| if wait < 0 { | ||
| wait = 0 | ||
| } | ||
|
|
||
| s.logger.Warnf("Retried %v time, going to sleep %v before retrying.", totalRetries, wait) | ||
|
|
||
| select { | ||
| case <-s.stopCh: | ||
| s.logger.Errorf("Stop requested after %v retries to %v/%v failed for PutLogEvents, request dropped.", retryCountShort+retryCountLong-1, batch.Group, batch.Stream) | ||
| s.logger.Errorf("Stop requested after %v retries to %v/%v failed for PutLogEvents, request dropped.", totalRetries, batch.Group, batch.Stream) | ||
| batch.updateState() | ||
| return | ||
| case <-time.After(wait): | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.