On 24-12-2014 09:22, brucedickin...@wp.pl [firebird-support] wrote: > I have a very simple table: > > CREATE TABLE PARAMS > ( > ID INTEGER NOT NULL, > NAME VARCHAR(32) NOT NULL, > CONSTRAINT PK_PARAMS PRIMARY KEY (ID), > CONSTRAINT UNQ_PARAMS UNIQUE (NAME) > ); > > I have two threads which constantly and at the same time are writing to > this table: > > UPDATE OR INSERT INTO PARAMS (NAME) VALUES(:P_NAME) MATCHING (NAME) > RETURNING ID; > > I've set my transaction parameters like this: > > FtraMain.TRParams.Add('isc_tpb_write'); > FtraMain.TRParams.Add('isc_tpb_read_committed'); > FtraMain.TRParams.Add('isc_tpb_wait'); > FtraMain.TRParams.Add('isc_tpb_no_rec_version'); > > As far as I understand, such configuration should prevent deadlock > exception to occur. However, deadlock still occurs from time to time: > > Deadlock. > Deadlock. > Update conflicts with concurrent update. > Concurrent transaction number is 57258.
If there is a chance that they are updating the same record concurrently, you will simply get a lock conflict; I don't think there is a way around this. Mark -- Mark Rotteveel