Skip to content

[v17] Fix large event handling for DynamoDB backend#63562

Merged
kshi36 merged 1 commit intobranch/v17from
kevin/backport-62899-branch/v17
Feb 9, 2026
Merged

[v17] Fix large event handling for DynamoDB backend#63562
kshi36 merged 1 commit intobranch/v17from
kevin/backport-62899-branch/v17

Conversation

@kshi36
Copy link
Copy Markdown
Contributor

@kshi36 kshi36 commented Feb 5, 2026

Backport #62899 to branch/v17

Manual backport to use dynamoevents old sub-pagination solution.

changelog: Fixed bug where event handler would get stuck on DynamoDB backend when handling large events


// saveCheckpointAtEvent generates a sub-page checkpoint at the event causing a page break.
// Subsequent processing will resume from this exact event.
func (l *eventsFetcher) saveCheckpointAtEvent(e event, oldIterator string) error {
Copy link
Copy Markdown
Contributor Author

@kshi36 kshi36 Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revised function saveCheckpointAtEvent to envelope the old sub-page checkpoint logic

Comment on lines -1478 to 1502
return out, true, nil
// We reached the response size limit.
// Either we reach the fetch limit (l.left == 0) or we have more items to process.
// For the latter, we must loop one more time to save the sub-page checkpoint at the next event,
// where we will resume future processing.
data = trimmedData
}
l.totalSize += len(data)
out = append(out, e)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of the way sub-page checkpoints work in branch/v17 (old sub-pagination solution), we must save at the next event, not the last processed event in out slice. We simply perform one more loop iteration, which will trigger this logic to save at next event:

		if l.totalSize+len(data) > events.MaxEventBytesInResponse {
			// Encountered an event that would push the total page over the size limit.
			// Return all processed events, and the next event will be picked up with the old iterator and saved sub-page checkpoint.
			if len(out) > 0 {
				if err := l.saveCheckpointAtEvent(e, oldIterator); err != nil {
					return nil, false, trace.Wrap(err)
				}
				return out, true, nil
			}

Comment on lines +861 to +868
mockResponses: map[EventKey]mockResponse{
{}: {
events: []apievents.AuditEvent{event1, event2, event3, bigUntrimmableEvent},
},
},
// we don't expect bigUntrimmableEvent because it should go to next batch
wantEvents: []apievents.AuditEvent{event1, event2, event3},
wantKey: keyUntrimmable,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All tests expect key of the next processed event (the big trimmable/untrimmable events)

@kshi36 kshi36 marked this pull request as ready for review February 5, 2026 23:21
@github-actions github-actions bot requested a review from juliaogris February 5, 2026 23:22
@github-actions github-actions bot added audit-log Issues related to Teleports Audit Log backport size/md labels Feb 5, 2026
@kshi36 kshi36 added this pull request to the merge queue Feb 9, 2026
Merged via the queue into branch/v17 with commit 7024c05 Feb 9, 2026
43 checks passed
@kshi36 kshi36 deleted the kevin/backport-62899-branch/v17 branch February 9, 2026 18:04
This was referenced Feb 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

audit-log Issues related to Teleports Audit Log backport size/md

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants