fix: fix a bug when the same transaction inserts and deletes the same data #24
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.
问题:同一事务对同一数据进行插入和删除时存在bug
描述:当在一个事务中插入一条数据并删除这条数据后提交该事务,后续事务仍然可见这条数据
分析:OperationSet(aka unordered_set)由于无法区分INSERT和DELETE操作,将这两种操作判定为重复操作,因此DELETE操作不会被记录在IOperationSet中,导致虽然同学们编写的接口delete_record中将end_xid 设为对应负值,但是commit的时候没有记录这个删除操作,因此end_xid并未被设置为commit_id,仍为负值。于是影响后续visit_record。
解决办法:修改OperationSet的判断元素相等和计算哈希方法,使其能够区分对同一数据不同类型的操作。
感谢李祥瑞同学提供的图片!