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 problem does this PR solve?
Issue
The scenario with error is as below. Create index erases table cache, and then show index adds a new table cache. Optimize index intends to add index info to table cache, but it can not see index1, so the index info in table cache is not latest. Then snapshot reads the wong index info in table cache.
create index (idx1)-------show index ------snapshot
** |---------------optimize-------------------------------|
Solution
We allow txn to change the table cache only when the txn begins after all committed write txns.
If it is conflicted with any committed write txn, the info it intends to change to the table cache may be not correct.
Type of change