Sašo
03/01/2024, 4:24 PMnewSuspendedTransaction
and withSuspendTransaction
, with comments explaining that the blocks will be run separately in "some thread from the dispatcher" (unclear if this is the same thread or multiple threads from same dispatcher) but both reusing the same transaction. However, just a couple of lines lower, there is a warning about not sharing a transaction between multiple threads. I am not sure if the example is doing just that (sharing a transaction between multiple threads), but regardless of that, I'm curious what the example would look like if there was a suspending function added to the mix, that also needs to reuse the same transaction.
In order to not do https://xyproblem.info/ , I am trying to implement a standard queue using a postgres table, basically a SELECT * FROM queue WHERE somecolumn IS NULL FOR UPDATE SKIP LOCKED
-> do some work that might or might not include suspending functions and will also need to do additional database queries, so I definitely want to reuse the existing transaction/connection -> set somecolumn
to the finish time.
Appreciate any help or pointers to examples!