While I was experimenting with transactions, I found a case that according to the documentation should not fail.
The documentation says:
If two transactions conflict - that is, they’ve written to the same row of a data table, or one transaction writes into a row another is reading from - one or both of them will be aborted.
The following two snippets read one row from the same table and update it. They don’t update the same row, so the transaction should not fail, but if I run them on two Python consoles at the same time, one of the two transactions fails.
Import and uplink connection:
import anvil.server, tables, time
anvil.server.connect("<connection string>")
Script on the first console:
with tables.Transaction():
row = tables.app_tables.my_table.get(col_1='test 1')
row['col_2'] = '1'
time.sleep(2)
row['col_2'] = '2'
Script on the second console:
with tables.Transaction():
row = tables.app_tables.my_table.get(col_1='test 2')
row['col_2'] = '1'
time.sleep(2)
row['col_2'] = '2'