noctonura
noctonura

Reputation: 13121

Transaction pattern for Azure Table Storage across multiple tables?

Are there any software patterns that would enable a transaction across multiple tables in Azure Table Storage?

I want to write (or delete) several entities from different tables in atomic way like...

try {
  write entity to table A
  write entity to table B
} catch {
  delete entity from table A
  delete entity from table B
}

During the above transaction I also want to prevent anyone from writing/deleting the same entities (same table, partition key and row key).

I know Azure Storage does not support this directly so I'm looking for a pattern perhaps using an additional table to "lock" entities in the transaction until its complete. All writers would have to obtain a lock on the entities.

Upvotes: 3

Views: 813

Answers (1)

Justin Patten
Justin Patten

Reputation: 1069

The only way to ensure that no one else modifies rows in a table while you are working on them is to add the overhead of blob leasing. You can have the one instance/thread grab the blob lease and do whatever it needs to. Then, when done, release the blob. If it fails to grab the lease, it either has to wait or try again later.

The other table based operations, like pessimistic concurrency, will not actually prevent someone from modifying the records.

Upvotes: 1

Related Questions