You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am a bit confused about how the queue#lock function works since the switch to the FOR NO KEY UPDATE SKIP LOCKED. When I look at the PostgreSQL manuals, it indicates that the row level locking will happen within a DB transaction; and when a SELECT FOR NO KEY UPDATE SKIP LOCKED finds a row within a DB transaction; any other DB sessions will skip that row when using the same FOR NO KEY ....
I don't see that QC does any DB transactions anywhere; so how does this work?
Why is there no ORDER BY id ASC in the query so that jobs are handled in FIFO manner?
Your title question. :) It doesn't matter where the workers are running if you have just one database. The database is the place where FOR NO KEY UPDATE SKIP LOCKED runs its logic and that is on one server. If you have multiple master database's then that's a completely different story.
Every SQL query is implicitly wrapped in a transaction by the database itself. It's equivalent to you wrapping each single query with BEGIN ... COMMIT.
Because there is no FIFO guarantee. FIFO is meaningless anyway, unless you will run exactly one worker. Even if you added mechanisms to have workers pull them in FIFO manner, workers will process them at varying speeds to FIFO order could break there. And if you're not providing a hard guarantee ORDER BY is just additional load on the database. In reality, database will in most cases return it in the order of creation due to how the data is laid out internally but it's much faster if it doesn't have to guarantee it. ORDER BY requires at least one sorting pass, even if the rows are in reality already sorted.
This discussion was converted from issue #345 on March 21, 2024 21:22.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
queue#lockfunction works since the switch to theFOR NO KEY UPDATE SKIP LOCKED. When I look at the PostgreSQL manuals, it indicates that the row level locking will happenwithin a DB transaction; and when a SELECTFOR NO KEY UPDATE SKIP LOCKEDfinds a row within a DB transaction; any other DB sessions will skip that row when using the sameFOR NO KEY ....I don't see that QC does any DB transactions anywhere; so how does this work?
ORDER BY id ASCin the query so that jobs are handled in FIFO manner?Thanks
All reactions