4 ms·
In that case you can (should) just "SELECT ... FOR UPDATE" in your transaction. This should prevent the issue. Client B will wait with the read until client A c
by viraptor 13y ago
In that case you can (should) just "SELECT ... FOR UPDATE" in your transaction. This should prevent the issue. Client B will wait with the read until client A commits.
- AlisdairO 13y agoOr you can use serialisable transaction isolation and retry on conflict.
- jeltz 13y agoI am pretty sure that just running UPDATE is enough. If an UPDATE happens to get stuck waiting for a lock it is re-evaluated. EDIT: Found where it is explained in the documentation. I do not see why this should not also apply to JSON. http://www.postgresql.org/docs/9.3/static/transaction-iso.html#XACT-READ-COMMITTED http://www.postgresql.org/docs/9.3/static/transaction-iso.ht...
- p4lindromica 13y ago... or you can include an ETag (optimistic lock) in your rows/mongo documents and do a conditional update to ensure no writes are interposed with your reads.