Pessimistic lock & rollback to savepoint = loosing changes??

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
jbakuwel
Posts: 35
Joined: Tue 02 Feb 2010 04:47

Pessimistic lock & rollback to savepoint = loosing changes??

Post by jbakuwel » Tue 27 Sep 2011 00:00

Hi,

Delphi 2010 UniDAC (3.50.0.13) with PostgreSQL (SecureBridge 3.00.0.2). I have two tables, A and B in a master detail relationship. I'm using pessimistic locking with a TUniQuery on table A and I'm not using CachedUpdates. I start a transaction, then edit the master record A and add a record to table B using another TUniQuery. When done I post the records and commit the transaction. The events I observe (with dbMonitor) are:

Start:
Savepoint LOCK_qTableA
Select * from TableA
Insert into B
Rollback to savepoint LOCK_qTableA (???????)
Commit

I guess 'm not surprised that this confirms my observation of loosing the updates.

Can you please explain why UniDAC is executing a Rollback to savepoint?

kind regards,
Jan

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Tue 27 Sep 2011 08:31

Hello,

I cannot reproduce the problem.
Please try to download the latest version of UniDAC (4.0.1) and SecureBridge (3.00.0.6) and reproduce the problem with these product versions.
If you reproduce the problem, please send us a demo project and a script to create tables to alexp*devart*com. Also please specify the exact versions of your IDE and PostgreSQL.

jbakuwel
Posts: 35
Joined: Tue 02 Feb 2010 04:47

Post by jbakuwel » Tue 27 Sep 2011 09:02

Hi Alex,

I have a bit more information. Please note that although I do call the Edit method of the Dataset for record A I do not change anything. The workaround I have found is to always update the master record when updating a detail record (fortunately I have something sensible to update in the master record). The events I observe in that case are:

Start:
Savepoint LOCK_qTableA
Select * from TableA
Update A ...
Insert into B ...
Commit

(ie there is no release savepoint but as far as I know that is not required)

I have scheduled an update of components in a couple of weeks, at which time I'll also upgrade UniDAC.

thanks,
Jan

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Wed 28 Sep 2011 09:46

Hello,

Please send your piece of code starting with StartTransaction and ending with Commit in which you edit and insert records.

Post Reply