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

configurable upper bound on locking attempt timeout #275

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ncleaton
Copy link

@ncleaton ncleaton commented Jun 1, 2021

I would like to repack a busy table with minimal impact, and the hard-coded 1000ms statement timeout upper bound on exclusive lock attempts makes more disruption than I would like, by delaying latency-sensitive queries by up to 1 second. For this table, it would be better to have a very short timeout on exclusive lock attempts combined with many retries over a long period.

I've added a sleep so that reducing the lock timeout does not also make the lock retries more frequent.

@ncleaton
Copy link
Author

ncleaton commented Jun 4, 2021

I did some test runs, on a table with frequent small updates and lots of read traffic of mixed statement duration, with some read queries taking many seconds. Graphing the duration of the normally-quick statements shows the impact of the pg_repack. The scripts and raw data for these tests are at https://github.com/ncleaton/pg_repack_mr_275

With unpatched pg_repack I get the results graphed below. You can see the impact on normally very cheap queries of the multiple exclusive lock attempts at various stages of the pg_repack:

unpatched

With the first commit of this branch applied and -m 10 in the options, it takes more tries to get the locks so the process takes longer, and the impact on normally fast queries lasts longer but is less severe. There's a short spike of slowness after the exclusive lock for the table swap is obtained, because the repack log has grown large during the long time it took to get the lock, so the final log replay while holding an exclusive lock takes a while:

first patch and -m 10

With the second patch applied there is less log to replay at the end, and I get:

both patches and -m 10

These runs are not very repeatable as there's a lot of luck in how long it takes to get each exclusive lock, but I haven't cherry picked them to make the patched versions look artificially good, honest.

@ncleaton ncleaton changed the title WIP configurable upper bound on locking attempt timeout configurable upper bound on locking attempt timeout Jun 6, 2021
@andreasscherbaum
Copy link
Collaborator

@ncleaton Can you please rebase this patch? This will also trigger the checks.

@ncleaton
Copy link
Author

I rebased and replied, I don't think this is "waiting for author" any more

@ncleaton
Copy link
Author

oh it needed rebasing again for another conflict 🤦‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants