-
Notifications
You must be signed in to change notification settings - Fork 59
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: constraint check exception with snapshot memory leak in AO/AOCS #136
Conversation
66659dc
to
0e60b4c
Compare
0e60b4c
to
7fdf693
Compare
Need a rebase. |
_bt_check_unique(DirtySnapshot is created here) -> table_index_fetch_tuple_check -> ... -> AppendOnlyVisimapStore_Init -> RegisterSnapshot(snapshot) UnregisterSnapshot is called in AppendOnlyVisimapStore_Finish. If transaction aborts, there is no chance to call AppendOnlyVisimapStore_Finish. In order to solve this problem, we directly delete the RegisterSnapshot in AppendOnlyVisimapStore_Init which is useless and at the same time delete the UnregisterSnapshot.
7fdf693
to
b570b3d
Compare
@lss602726449 , @avamingli , @my-ship-it It seems that this fix has 2 problems:
|
Hi,thanks! Reasonable, +1. |
Thanks, it is my mistake. I'll fix this problem and test as you suggest |
@avamingli, @liming01
|
…#136) _bt_check_unique(DirtySnapshot is created here) -> table_index_fetch_tuple_check -> ... -> AppendOnlyVisimapStore_Init -> RegisterSnapshot(snapshot) UnregisterSnapshot is called in AppendOnlyVisimapStore_Finish. If transaction aborts, there is no chance to call AppendOnlyVisimapStore_Finish. In order to solve this problem, we directly delete the RegisterSnapshot in AppendOnlyVisimapStore_Init which is useless and at the same time delete the UnregisterSnapshot.
closes: #93
Change logs
This bug comes from AppendOnlyVisimapStore_Init calling RegisterSnapshot in appendonly_fetch_init, which creates a deep copy of the current snapshot. Therefore, when a constraint is violated(see function check_exclusion_or_unique_constraint in detail), EROOR will be performed directly, but UnregisterSnapshot in AppendOnlyVisimap_Finish is not called. Therefore, an Asset error will occur when the resource is finally recycled.
In order to solve this problem, we directly delete the RegisterSnapshot in AppendOnlyVisimapStore_Init which is useless and at the same time delete the UnregisterSnapshot.
Why are the changes needed?
FIX: constraint check exception with snapshot memory leak in AO/AOCS
Does this PR introduce any user-facing change?
No
How was this patch tested?
No need
Contributor's Checklist
Here are some reminders and checklists before/when submitting your pull request, please check them:
make installcheck
make -C src/test installcheck-cbdb-parallel