Many of the race conditions that can affect series of statements can also affect single statements with CTEs and subqueries, but the window in which they occur is narrower because the statement-parts usually run closer together. A subquery might run before the outer query, depending on how the planner/optimizer does things. This is harder than you’d think because SQL statements do not execute atomically. It is vital that each item get processed exactly once none may be skipped and none may be processed more than once.” Many other workers will be doing the same thing at the same time. “How do I find the first row (by some given ordering) in a queue table that nobody else has claimed and claim it for myself? It needs to automatically revert to being unclaimed again if I crash or exit for any reason. The hard part of the problem boils down to: “Find me the next unclaimed row” shouldn’t be hard, though, surely? Including the popular off-the-shelf ones that are known to work well. The few exceptions I’ve seen generally use PostgreSQL’s advisory locking features or use various time-and-expiry based methods of queue cleanup and recovery.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |