Database deadlocks

前端 未结 6 1500
鱼传尺愫
鱼传尺愫 2020-12-14 09:07

One of the classical reasons we have a database deadlock is when two transactions are inserting and updating tables in a different order.

For example, transaction A

6条回答
  •  悲&欢浪女
    2020-12-14 09:40

    I analyze all database actions to determine, for each one, if it needs to be in a multiple statement transaction, and then for each such case, what the minimum isolation level is required to prevent deadlocks... As you said serializable will certainly do so...

    Generally, only a very few database actions require a multiple statement transaction in the first place, and of those, only a few require serializable isolation to eliminate deadlocks.

    For those that do, set the isolation level for that transaction before you begin, and reset it whatever your default is after it commits.

提交回复
热议问题