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

Ignore other pg_repack clients in SQL_XID_SNAPSHOT #1

Closed
schmiddy opened this issue Nov 21, 2012 · 1 comment
Closed

Ignore other pg_repack clients in SQL_XID_SNAPSHOT #1

schmiddy opened this issue Nov 21, 2012 · 1 comment

Comments

@schmiddy
Copy link
Member

Thibaud WALKOWIAK complained recently about pg_repack clients having to wait on each other while concurrently operating on tables in the same database. Presumably this wait comes from the SQL_XID_SNAPSHOT check, which does not bother ignoring other pg_repack clients based on application_name.

I proposed a simple fix to have SQL_XID_SNAPSHOT ignore other pg_repack clients using pg_stat_activity.application_name here:
http://lists.pgfoundry.org/pipermail/reorg-general/2012-November/000137.html

(Will only help on 9.0 or later, since that's when we have application_name exposed.)

schmiddy added a commit that referenced this issue Dec 7, 2012
…the purposes of SQL_XID_SNAPSHOT.

Use application_name from pg_stat_activity, if available, to identify
other pg_repack clients. Fixes Issue #1.
@schmiddy
Copy link
Member Author

schmiddy commented Dec 9, 2012

Fixed in a072cc9 and f6ca290. The queries ended up tiny bit different than what I initially proposed:

  • make sure to explicitly exclude conn2 based on its backend PID, since we can't trust application_name in all cases (e.g. under installcheck, or on old versions)
  • use LEFT JOIN against pg_stat_activity, in case there are locks in pg_locks which don't show up in pg_stat_activity
  • don't hardcode the application_name 'pg_repack' in the query, just in case our PROGRAM_NAME is something different

@schmiddy schmiddy closed this as completed Dec 9, 2012
chanukyasds pushed a commit to chanukyasds/pg_repack that referenced this issue Jul 23, 2023
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