Subject | Re: update, foreign keys, locking |
---|---|
Author | Alexander V.Nevsky |
Post date | 2003-07-17T17:44:18Z |
--- In firebird-support@yahoogroups.com, "unordained"
<unordained_00@c...> wrote:
particular circuimstances it is appropriate. If you are sure you
really need pessimistic locking, I can suggest variants:
1. Make your "dummy update" in the same transaction which you'll use
to make reak updates
2. If you are trying to lock "header" of some complex (distributed
among several tables) object each time you have intention to work with
any of it's properties and you need different transactions to handle
properties, create additional table referenced 1:1 on "header" and
perform initial locking in this table, not in real "header".
Best regards, Alexander.
<unordained_00@c...> wrote:
> Unless I'm just off my rocker, I seem to remember that if you startupdating a row, rows referenced
> by foreign key values will also get locked on that same transaction(or at least attempt to do so --
> some sort of read-lock?) In our case, this meant that if you're inthe middle of updating
> someone's SSN, and you try to also update their address(popup-screen of dependent record on a
> different transaction) you'll get a deadlock (we use NOWAIT, so it'sat least not too irritating.)
>set id = id where id =
> (when someone starts editing, we explicitely do 'update {tablename}
> {value}' -- this conflicts with parent records already being edited.as we've already selected the
> data, we don't bother reselecting 'for update'.)Philip, can't say this is good techigue in general, but in
particular circuimstances it is appropriate. If you are sure you
really need pessimistic locking, I can suggest variants:
1. Make your "dummy update" in the same transaction which you'll use
to make reak updates
2. If you are trying to lock "header" of some complex (distributed
among several tables) object each time you have intention to work with
any of it's properties and you need different transactions to handle
properties, create additional table referenced 1:1 on "header" and
perform initial locking in this table, not in real "header".
Best regards, Alexander.