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

Inapposite usage of pgsp_tmp_entry->mutex #46

Open
ocean-dot-li opened this issue Dec 25, 2024 · 0 comments
Open

Inapposite usage of pgsp_tmp_entry->mutex #46

ocean-dot-li opened this issue Dec 25, 2024 · 0 comments

Comments

@ocean-dot-li
Copy link

ocean-dot-li commented Dec 25, 2024

Hello,
When I was reading the source code of pg_show_plans, I found that the usage of the spin lock pgsp_tmp_entry->mutex in the pg_show_plans function is inappropriate. Spinlock is very lightweight lock, so the reasonable usage should involve performing some simple logical operations while holding the spin lock. However, in the pg_show_plans function, the spin lock pgsp_tmp_entry->mutex is held during the execution of the heap_form_tuple operation, which could handle interrupt signals (e.g., multiple calls to ereport). This could result in spin lock leakage.

In my opinion, the mutex in pgspEntry is only used to protect n_plans. Therefore, it might be more appropriate to add a member n_plans in pgspCtx to record the n_plans information when pgsp_tmp_entry is acquired. And then, Release the spinlock. Please refer to the v1.patch for more details.

Regards.

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

No branches or pull requests

1 participant