c++ - libpqxx transaction serialization & consequences -


for implementation, particular write must done in bulk , without chance of interfering.

i have been told 2 competing transactions in way lead first 1 blocking second, , second may or may not complete after first has.

please post documentation confirms this. also, happens second transaction if first blocking? queued, fail, or combination?

if cannot confirmed, should transaction isolation level transaction set serializable? if so, how can done libpqxx prepared statements?

if transactions serialized, second transaction fail or queued until first has completed?

if either fail, how can detected libpqxx?

the way conclusively prevent concurrency effects lock table ... in access exclusive mode each table wish modify.

this means you're doing 1 thing @ time. leads fun problems deadlocks if don't acquire locks in same order.

so usually, need figure out operations wish are, , how interact. determine concurrency effects can tolerate, , how prevent cannot.

this question stands broad usefully answer.

options include:

  • exclusively locking tables. (this only way multi-row upsert without concurrency problems in postgresql right now). beware of lock upgrade , lock order related deadlocks.

  • appropriate use of serializable isolation - remember, have able keep record of did during transaction , retry if tx aborts.

  • careful row-level locking - select ... update, select ... share.

  • "optimistic locking" / optimistic concurrency control, appropriate

  • writing queries in ways make them more friendly toward concurrent operation. example, replacing read-modify-write cycles in-place updates.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -