Skip to content

[DRAFT][18.0] Use session-level advisory lock for requeuing jobs#907

Draft
guewen wants to merge 1 commit intoOCA:18.0from
guewen:18.0-advisory-lock-requeue
Draft

[DRAFT][18.0] Use session-level advisory lock for requeuing jobs#907
guewen wants to merge 1 commit intoOCA:18.0from
guewen:18.0-advisory-lock-requeue

Conversation

@guewen
Copy link
Member

@guewen guewen commented Feb 24, 2026

No description provided.

@OCA-git-bot
Copy link
Contributor

Hi @sbidoul,
some modules you are maintaining are being modified, check this out!

@guewen guewen force-pushed the 18.0-advisory-lock-requeue branch from fed50d4 to ffbc8f7 Compare February 24, 2026 16:56
@sbidoul
Copy link
Member

sbidoul commented Feb 24, 2026

I think we had considered that, but worried about potential conflicts with other advisory locks as it can potentially hit a wide range of lock ids. Not sure if we had thought about the two keys locks. As it is mentioned that the one key and two keys lock spaces do not overlap, maybe it's not an issue.

cc/ @AnizR

@sbidoul
Copy link
Member

sbidoul commented Feb 25, 2026

Ah, pgbouncer. Folks using pgbouncer have it with transaction-level pooling which is not compatible with session level advisory locks?

@guewen
Copy link
Member Author

guewen commented Feb 25, 2026

Ah, pgbouncer. Folks using pgbouncer have it with transaction-level pooling which is not compatible with session level advisory locks?

Yes, that's a problem. There is still the option to configure job workers to connect directly to the the database or to use pgdog that now seems to supports session-level advisory locks.

At first sight, that would be acceptable to me with a bump of the major version, but could be interesting to have more insights.

@guewen guewen force-pushed the 18.0-advisory-lock-requeue branch from ffbc8f7 to 0b64d37 Compare February 25, 2026 08:12
@sbidoul
Copy link
Member

sbidoul commented Feb 25, 2026

As a data point, pgbouncer is the one supported out of the box by cloudnative-pg and we consider using it more to leverage transparent switchover.

@guewen
Copy link
Member Author

guewen commented Feb 25, 2026

As a data point, pgbouncer is the one supported out of the box by cloudnative-pg and we consider using it more to leverage transparent switchover.

Interesting!

When looking for info, I found this saying they consider removing the pooler: cloudnative-pg/cloudnative-pg#6869 (comment). It's a tangeant because it might not change anything, but worth sharing anyway.

@AnizR
Copy link
Contributor

AnizR commented Feb 25, 2026

I think we had considered that, but worried about potential conflicts with other advisory locks as it can potentially hit a wide range of lock ids. Not sure if we had thought about the two keys locks. As it is mentioned that the one key and two keys lock

In deed, it was my first approach but, potential conflicts were the main worry and didn't thought of using 2 keys.

I think that we had another issue but can't remind which one.
Don't you have issues when having a rolling back caused by an error within a job?

Otherwise, the PR seems promising!

@guewen
Copy link
Member Author

guewen commented Feb 25, 2026

Don't you have issues when having a rolling back caused by an error within a job?

It shouldn't be an issue because the advisory lock used here is at the session level (connection), so transactional commit/rollbacks have no effect. As for releasing, there is a finally clause around the execution of the job that calls pg_advisory_unlock, so it will be released whether there is an error or not (and automatically released if the connection is closed because of a hard kill).

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.

4 participants