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

Possible deadlock in truncate scenerios #147

Open
yugo-n opened this issue Sep 6, 2022 · 1 comment
Open

Possible deadlock in truncate scenerios #147

yugo-n opened this issue Sep 6, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@yugo-n
Copy link
Collaborator

yugo-n commented Sep 6, 2022

Reported by huyajun in https://www.postgresql.org/message-id/tencent_FCAF11BCA5003FD16BDDFDDA5D6A19587809%40qq.com

There is a risk of deadlock that is also acceptable for truncate scenarios.
The deadlock scene is as follows:

View definition: select * from base_a,base_b;

S1: truncate base_a; — only AccessExclusiveLock base_a and not run into after trigger
S2: insert into base_b; — The update has been completed and the incremental refresh is started in the after trigger,RowExclusive on base_b and ExclusiveLock on mv
S1: continue truncate mv, wait for AccessExclusiveLock on mv, wait for S2
S2: continue refresh mv, wait for AccessShardLock on base_a, wait for S1
So deadlock occurred

@yugo-n yugo-n added bug Something isn't working question Further information is requested and removed bug Something isn't working question Further information is requested labels Sep 6, 2022
@yugo-n
Copy link
Collaborator Author

yugo-n commented Sep 6, 2022

I confirm that this deadlock occurs when S2 starts before the before trigger is fired in S1. (Note that the lock on mv is acquired in BEFORE trigger instead of AFTER.)

@yugo-n yugo-n added the enhancement New feature or request label Sep 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant