[PB-5865] fix(file-versioning): use updated tier data to apply version limits correctly #921
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.



What does this PR do?
Ensures that file version limits are correctly applied when users change their subscription plan.
Why are we doing this?
When users upgrade or downgrade their subscription, file versions should be adjusted according to their new plan limits. Previously, the version cleanup process was not executing reliably because it was using outdated plan information.
How are we doing this?
Instead of querying the user's plan information from the database after updating it, we now use the plan information that was just updated. This prevents reading stale data and ensures version limits are applied immediately and accurately.
Should this be manually tested & how?
This was tested locally by executing the complete end-to-end flow:
Any background context?
This fix addresses a production issue where file versioning cleanup had inverted behavior during plan changes. Plan limits determine version retention policies, and using fresh plan data ensures these policies are enforced correctly. This issue only occurs in production and is not reproducible in test environments. We suspect this is caused by a race condition, database caching, or reading from different database instances (replicas) when querying user plan information immediately after updating it.