versioned: Never clean up current version #35190
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.
Current version of a versioned.Value is the latest committed version. This version should never be cleaned off, as then no value would be available. Currently this can happen if there is a new transaction in progress due to a missing check between the oldest handle version (for the new transaction) and the current version. Add this check using 'min()'.
This fixes the following warning log:
2024-10-03T06:14:48.362931495Z time="2024-10-03T06:14:48.361323126Z" level=warning msg="GetVersionHandle: Handle to a stale version requested, returning oldest valid version instead" oldVersion=1 stacktrace="<stacktrace redacted>" subsys=policy version=2
In the above log 'oldVersion' (1) was the current version that was cleaned off due to the oldest version handle being for a new, non-committed transaction for version 2.
When this line was logged, a handle for version 2 was returned, resulting in a race between the use of that version and that version being committed. Never cleaning off the current version makes sure this does not happen.
Fixes: #34205