Files
tasks/common/persistence/sql/sqlplugin/sqlite
Prathyush PVandGitHub d98eb745ad Adding FOR UPDATE for SelectFromQueueV2Metadata (#5075)
<!-- Describe what has changed in this PR -->
**What changed?**
Adding FOR UPDATE clause when fetching queueV2 metadata and removing
unused field version from queue metadata.

<!-- Tell your future self why have you made these changes -->
**Why?**
If a queueV2 metadata row is fetched in a transaction, we have to place
a lock on that row
to avoid another transaction reading from that line. This can happen
when two threads are trying to
delete messages from the queue. Two of them will update queue metadata
and write it back. This will lead
to a race condition. By adding 'FOR UPDATE' SQL clause, the first
transaction will get an exclusive lock
on the row. The second transaction will wait until the first transaction
is complete or rollback.

Also, removing the version field from QueueV2 metadata table. We will
not be using this field since we are using sql transactions.


<!-- How have you verified this change? Tested locally? Added a unit
test? Checked in staging env? -->
**How did you test it?**
Unit test. Executed through the debugger to make sure
SelectFromQueueV2MetadataForUpdate() is called instead of
SelectFromQueueV2Metadata() when executed inside a trancation.


<!-- Assuming the worst case, what can be broken when deploying this
change to production? -->
**Potential risks**


<!-- Is this PR a hotfix candidate or require that a notification be
sent to the broader community? (Yes/No) -->
**Is hotfix candidate?**
2023-11-04 09:56:35 -07:00
..
2022-04-13 15:29:38 -07:00
2022-04-13 15:29:38 -07:00
2022-04-13 15:29:38 -07:00
2023-06-09 10:36:38 -07:00