Skip to content

fix: Quadruple max_locks_per_transaction#1165

Open
Erethon wants to merge 1 commit into
NixOS:mainfrom
Erethon:max_locks
Open

fix: Quadruple max_locks_per_transaction#1165
Erethon wants to merge 1 commit into
NixOS:mainfrom
Erethon:max_locks

Conversation

@Erethon

@Erethon Erethon commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

The default for this setting is 64, let's quadruple it to allow for bigger batch sizes.

@fricklerhandwerk @adekoder did you do any fine-tuning on that 10k rows batch size when testing the PR? I believe lowering that would also help, but I don't know how it would impact speed.

Closes #1153

@fricklerhandwerk

Copy link
Copy Markdown
Collaborator

I ran it with default Postgres settings locally a couple of times, without other concurrent things going on. Larger batch sizes (e.g. 20k, 50k) would error out on their own in the beginning when each batch would produce new packages/attributes. But I didn't do any rigorous measurement, so I don't even know how that 64 figures into a batch size of 10k.

Comment thread infra/production.nix
max_parallel_workers_per_gather = "4";
max_parallel_workers = "8";
max_parallel_maintenance_workers = "4";
max_locks_per_transaction = "256";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about we move that into right into configuration.nix and say why it's need to be like that? I don't think this setting is in any way specific to any deployment.

@fricklerhandwerk fricklerhandwerk Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed with @Erethon:

  • The number of advisory locks is x <max_locks> (200x64 = 12400)
    • That explains why running batches locally didn't allow for more than 10k
  • Bumping to 256 will give us >50k slots, which should be plenty at that batch size
  • We should move it to configuration.nix because it's an application-level requirement

@fricklerhandwerk

Copy link
Copy Markdown
Collaborator

@Erethon I added a commit to avoid operators having to think about the setting if they don't want to, please take a look.

@fricklerhandwerk fricklerhandwerk marked this pull request as ready for review July 8, 2026 11:01
@fricklerhandwerk fricklerhandwerk requested a review from adekoder July 8, 2026 11:01
Comment thread nix/configuration.nix Outdated
Comment thread nix/configuration.nix Outdated
The default for this setting is 64, let's quadruple it to allow for
bigger batch sizes.

Closes NixOS#1153
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

Successfully merging this pull request may close these issues.

Increase lock limit

2 participants