Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix a bug when the same transaction inserts and deletes the same data #24

Merged
merged 6 commits into from
May 31, 2024

Conversation

ntw2020
Copy link
Contributor

@ntw2020 ntw2020 commented May 30, 2024

问题:同一事务对同一数据进行插入和删除时存在bug

描述:当在一个事务中插入一条数据并删除这条数据后提交该事务,后续事务仍然可见这条数据

分析:OperationSet(aka unordered_set)由于无法区分INSERT和DELETE操作,将这两种操作判定为重复操作,因此DELETE操作不会被记录在IOperationSet中,导致虽然同学们编写的接口delete_record中将end_xid 设为对应负值,但是commit的时候没有记录这个删除操作,因此end_xid并未被设置为commit_id,仍为负值。于是影响后续visit_record。

f02f7094947c31de35cc08e7917222c
解决办法:修改OperationSet的判断元素相等和计算哈希方法,使其能够区分对同一数据不同类型的操作。

感谢李祥瑞同学提供的图片!

@ycycse ycycse requested a review from RkGrit May 30, 2024 15:31
@ycycse ycycse changed the title fix: fix a bug when the same transaction inserts and deletes the same data in TDB/src/server/include/storage_engine/transaction/trx.h fix: fix a bug when the same transaction inserts and deletes the same data May 30, 2024
@RkGrit RkGrit merged commit 328df69 into THSS-DB:master May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants