fix duplicate session recording creation #45877
Merged
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.
Fixes an issue where duplicate session recordings could end up being created in teleport clusters experiencing interruptions during session recording upload from agent to auth. In all observed cases of this bug, it seems to have been produced by a combination of two factors:
Both of the above cases are addressed in this PR. Note, however, that this PR does not address correctly selecting the non-empty upload for existing recordings affected by this issue. That will have to be the subject of future work (see #45917). It also doesn't prevent duplicates due to loss of agent-side cursor state or timeout of a partially completed upload attempt (e.g. due to an agent being offline for a prolonged period of tim), both of which were previously known "expected" cases in which duplicate recordings could be produced.
This issue is loosely related to #45786 as the two issues tend to happen together since they are both triggered when the session recording system is under extremely high load.
changelog: fixed an issue that could result in duplicate session recordings being created