2

If two transactions (both at RR isolation level) ask for the same item which is 2nd-level cached, and then they modify and store this item. Now, for reading that item, they did not run any SQL because it's cached; so in this case, will they actually start a data base transaction? And when they commit their changes, will they run into lost update problem?

4

1 に答える 1

1

悲観的な観点から:

第2レベルのキャッシュがトランザクションに参加するように構成されている場合、最初に書き込みロックを取得したキャッシュのみが、キャッシュされたオブジェクトを変更して、データベースに変更を書き込むことができます。2番目のトランザクションが書き込みロックを取得する場合、最初のトランザクションが終了して解放するまで待機する必要があります。

楽観的ロックを使用すると、同時変更例外(または同様の名前)が発生し、2番目のトランザクションが操作を再試行すると思います。

于 2012-04-05T14:25:47.187 に答える