#1  
Old 24th November 2015, 11:52 PM
sri.ajay sri.ajay is offline
Junior Member
 
Join Date: Oct 2015
Posts: 10
Default Content Locks and Transactions work

This below statement is copied from here: "https://www.nexusdb.com/support/index.php?q=howcontentlocksandtransact.htm"

"In addition to the above. When a content lock, no matter of record or table level gets released in the context of a transaction. Then ALL
attempts to acquire new content locks, no matter which type, have to wait for that transaction to finish.
"

I have tested the scenario explained in the above statement but unfortunately this does not look true. Following is what i have done:
Within a transaction context, Record 1(R1) gets content lock and posted the data thereby releasing the content lock. however transaction is not committed or rolled back. Another user also tries to edit R1 and gets the content lock on R1.


This above scenario is not working fine and we can get content lock which goes against the statement given in the above link.

Can somebody please explain me if my understanding is correct? or may i know if the above link is updated to suit latest v4 version? In that case, please confirm.
  #2  
Old 25th November 2015, 01:56 AM
Thorsten Engler [NDA]
 
Posts: n/a
Default Re: Content Locks and Transactions work

Hi,

TnxTableLockContainer (in nxsrTableLockContainer.pas) has a field tlcTrans.

In ReleaseRecordLock, BeginTransaction (which sets tlcTrans) is being called if
ReleaseRecordLock took place in context of a transaction.

In GetRecordLock, there is a check:

if not Assigned(tlcTrans) or (aTrans = tlcTrans) then

which means that if a previous ReleaseRecordLock has set tlcTrans, new record
locks should only be able to be granted if they come in the context of the same
transaction that previously released the record lock. (This will NOT affect any
record locks that might already be in place, only new record locks).

As far as I can determine the code is correct to implement the stated behavior:

> "-In addition to the above. When a content lock, no matter of record or
> table level gets released in the context of a transaction. Then ALL
> attempts to acquire new content locks, no matter which type, have to
> wait for that transaction to finish.-"


If you think there is a problem, could you please provide a self-contained
testcase that demonstrates the problem? (Using a TnxServerEngine and two
TnxSessions).

Cheers,
Thorsten


sri.ajay wrote:

>
> This below statement is copied from here:
> "https://www.nexusdb.com/support/index.php?q=howcontentlocksandtransact.htm"
>
> "-In addition to the above. When a content lock, no matter of record or
> table level gets released in the context of a transaction. Then ALL
> attempts to acquire new content locks, no matter which type, have to
> wait for that transaction to finish.-"
>
> I have tested the scenario explained in the above statement but
> unfortunately this does not look true. Following is what i have done:
> -Within a transaction context, Record 1(R1) gets content lock and posted
> the data thereby releasing the content lock. however transaction is not
> committed or rolled back. Another user also tries to edit R1 and gets
> the content lock on R1.
> -
>
> This above scenario is not working fine and we can get content lock
> which goes against the statement given in the above link.
>
> Can somebody please explain me if my understanding is correct? or may i
> know if the above link is updated to suit latest v4 version? In that
> case, please confirm.


  #3  
Old 26th November 2015, 03:13 AM
sri.ajay sri.ajay is offline
Junior Member
 
Join Date: Oct 2015
Posts: 10
Default unable to upload illustration video

> If you think there is a problem, could you please provide a self-contained
> testcase that demonstrates the problem? (Using a TnxServerEngine and two
> TnxSessions).

I have prepared a sample application and created an video for illustrating the problem but unfortunately i cannot upload that video. The extension of that file is .wmv. I zipped it as well but still it cannot be uploaded as i am always getting "Invalid file" message.

Can you please let me some other way to upload the file?


> if a previous ReleaseRecordLock has set tlcTrans, new record
> locks should only be able to be granted if they come in the context of the > same transaction that previously released the record lock.
I do not think that it is only working as mentioned above. I can get content lock from another cursor which is outside of transaction. Let me know if you need the sample application with source code as well.
  #4  
Old 26th November 2015, 08:23 AM
Eivind Bakkestuen [NDD]
 
Posts: n/a
Default Re: Content Locks and Transactions work

> I have prepared a sample application and created an video for
> illustrating the problem but unfortunately i cannot upload that video.
> The extension of that file is .wmv. I zipped it as well but still it
> cannot be uploaded as i am always getting "Invalid file" message.


I'm sure the source of the sample application and a textual description
of what we need to do (eg, "click button blah", etc) will do fine to
reproduce; I doubt a video is necessary (but thanks for taking the
time).

> Can you please let me some other way to upload the file?


These days, something like Dropbox appears to be the popular way to
share files. But again, I'd rather ask for spelled out steps; I'm
assuming the sample app can't be that complicated.

--
Eivind Bakkestuen [NDD]
  #5  
Old 26th November 2015, 03:38 PM
sri.ajay sri.ajay is offline
Junior Member
 
Join Date: Oct 2015
Posts: 10
Default Steps to reproduce and link to sample source code

Thanks Elvind. Here are the steps:

Prerequisites:
1) Two DB connections(with theiw own sets of session, transport etc...). LEt call them DB1 and DB2.
2) Two TnxTable component(Tbl1 and Tbl2) connected to DB1 and DB2. Both pointing to the same table and same record.
3) I ahve used Sample NorthWind database, Orders table, CustomerID='VINET' and updating Freight field.

Steps to reproduce the issue:
1) DB1.StartTransaction Start transaction on DB1
2) Edit DB1.Tbl1.R1.Field1 - Modify the current value after geting content lock.
3) Post DB1.Tbl1.R1.Field1 - Data is posted, but as it is still in transaction, DB2 cannot see this. Content lock released.
4) DB2.Tbl2.Refresh - Will see the old value before it was modified by DB1.Tbl1
4) Edit DB2.Tbl2.R1.Field1 - Modify the current value. Content lock acquired.
5) Post DB2.Tbl2.R1.Field1 - Data is not posted as this table is already in transaction(Exclusive lock by DB1), Lock timeout error is thrown.
6) DB1.Commit.
7) Post DB2.Tbl2.R1.Field1 - Data is posted - ERROR!!!! User has not updated an old value thinking that the value he is seeing is latest one. Data integrity lost.
8) DB1.Tbl1.Refresh will see the new value which was modified by DB2.Tbl2.

I have also uploaded source code and video for your reference. Following is the links:
https://www.dropbox.com/s/lbti6xr6wu..._V1.zip?oref=e
  #6  
Old 26th November 2015, 07:05 PM
Thorsten Engler [NDA]
 
Posts: n/a
Default Re: Content Locks and Transactions work

I haven't checked out your code yet, but a simple testcase following your
description:

object nxServerEngine1: TnxServerEngine
ServerName = ''
Options = []
TableExtension = 'nx1'
end
object nxSession1: TnxSession
ServerEngine = nxServerEngine1
end
object nxSession2: TnxSession
ServerEngine = nxServerEngine1
end
object nxDatabase1: TnxDatabase
Session = nxSession1
AliasPath = 'D:\Northwind'
end
object nxDatabase2: TnxDatabase
Session = nxSession2
AliasPath = 'D:\Northwind'
end
object nxTable1: TnxTable
Database = nxDatabase1
TableName = 'Orders'
end
object nxTable2: TnxTable
Database = nxDatabase2
TableName = 'Orders'
end

procedure TForm3.Button1Click(Sender: TObject);
begin
nxTable1.Open;
nxTable2.Open;

nxDatabase1.StartTransaction;

nxTable1.Edit;
nxTable1.FieldByName('Freight').AsInteger := 100;
nxTable1.Post;

nxTable2.Refresh;

nxTable2.Edit; //<-- exception
nxTable2.FieldByName('Freight').AsInteger := 200;
nxTable2.Post;

//...
end;

Produces the following (correct) exception on the nxTable2.Edit line:

---------------------------
Project4
---------------------------
NexusDB: nxTable2: Record locked by another user.

The requested content record lock could not be granted due to a transaction
conflict.

The conflict occurred with the following session:
Connected since: 26/11/2015 18:01:17
anonymous User
Connected from: direct

[$2801/10241].
---------------------------
OK
---------------------------

Meaning that nxTable2 never entered edit mode.


sri.ajay wrote:

>
> Thanks Elvind. Here are the steps:
>
> Prerequisites:
> 1) Two DB connections(with theiw own sets of session, transport etc...).
> LEt call them DB1 and DB2.
> 2) Two TnxTable component(Tbl1 and Tbl2) connected to DB1 and DB2. Both
> pointing to the same table and same record.
> 3) I ahve used Sample NorthWind database, Orders table,
> CustomerID='VINET' and updating Freight field.
>
> Steps to reproduce the issue:
> 1) DB1.StartTransaction Start transaction on DB1
> 2) Edit DB1.Tbl1.R1.Field1 - Modify the current value after geting
> content lock.
> 3) Post DB1.Tbl1.R1.Field1 - Data is posted, but as it is still in
> transaction, DB2 cannot see this. Content lock released.
> 4) DB2.Tbl2.Refresh - Will see the old value before it was modified by
> DB1.Tbl1
> 4) Edit DB2.Tbl2.R1.Field1 - Modify the current value. Content lock
> acquired.
> 5) Post DB2.Tbl2.R1.Field1 - Data is not posted as this table is already
> in transaction(Exclusive lock by DB1), Lock timeout error is thrown.
> 6) DB1.Commit.
> 7) Post DB2.Tbl2.R1.Field1 - Data is posted - ERROR!!!! User has not
> updated an old value thinking that the value he is seeing is latest one.
> Data integrity lost.
> 8) DB1.Tbl1.Refresh will see the new value which was modified by
> DB2.Tbl2.
>
> I have also uploaded source code and video for your reference. Following
> is the links:
> https://www.dropbox.com/s/lbti6xr6wu..._V1.zip?oref=e


  #7  
Old 26th November 2015, 07:50 PM
Thorsten Engler [NDA]
 
Posts: n/a
Default Re: Content Locks and Transactions work

I tried your test project, and it also behaves correctly:

- click "Connect"
- "Transaction 1" box - click "Start Trans"
- change value in New Val / DS1 edit box
- click "Post DS1"
- click "refresh DS3" - still shows old value
- attempt(!) to change value in New Val / DS3 edit box

attempt fails (no content lock acquired) with the following exception:
---------------------------
Transaction
---------------------------
NexusDB: nxTable3: Record locked by another user.

The requested content record lock could not be granted due to a transaction
conflict.

The conflict occurred with the following session:

Connected since: 26/11/2015 18:45:07
anonymous User
Connected from: direct

[$2801/10241].
---------------------------
OK
---------------------------

I am so far unable to reproduce any problem with the locking system.


sri.ajay wrote:

>
> Thanks Elvind. Here are the steps:
>
> Prerequisites:
> 1) Two DB connections(with theiw own sets of session, transport etc...).
> LEt call them DB1 and DB2.
> 2) Two TnxTable component(Tbl1 and Tbl2) connected to DB1 and DB2. Both
> pointing to the same table and same record.
> 3) I ahve used Sample NorthWind database, Orders table,
> CustomerID='VINET' and updating Freight field.
>
> Steps to reproduce the issue:
> 1) DB1.StartTransaction Start transaction on DB1
> 2) Edit DB1.Tbl1.R1.Field1 - Modify the current value after geting
> content lock.
> 3) Post DB1.Tbl1.R1.Field1 - Data is posted, but as it is still in
> transaction, DB2 cannot see this. Content lock released.
> 4) DB2.Tbl2.Refresh - Will see the old value before it was modified by
> DB1.Tbl1
> 4) Edit DB2.Tbl2.R1.Field1 - Modify the current value. Content lock
> acquired.
> 5) Post DB2.Tbl2.R1.Field1 - Data is not posted as this table is already
> in transaction(Exclusive lock by DB1), Lock timeout error is thrown.
> 6) DB1.Commit.
> 7) Post DB2.Tbl2.R1.Field1 - Data is posted - ERROR!!!! User has not
> updated an old value thinking that the value he is seeing is latest one.
> Data integrity lost.
> 8) DB1.Tbl1.Refresh will see the new value which was modified by
> DB2.Tbl2.
>
> I have also uploaded source code and video for your reference. Following
> is the links:
> https://www.dropbox.com/s/lbti6xr6wu..._V1.zip?oref=e


  #8  
Old 26th November 2015, 08:46 PM
sri.ajay sri.ajay is offline
Junior Member
 
Join Date: Oct 2015
Posts: 10
Default

did u check the video?
  #9  
Old 26th November 2015, 09:03 PM
sri.ajay sri.ajay is offline
Junior Member
 
Join Date: Oct 2015
Posts: 10
Default

by the way, i am using nexus v3.08
  #10  
Old 26th November 2015, 09:40 PM
Thorsten Engler [NDA]
 
Posts: n/a
Default Re: Content Locks and Transactions work

sri.ajay wrote:

> by the way, i am using nexus v3.08


Then you are missing over 4 1/2 years of updates and bugfixes and we are just
wasteing time here.


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to avoid the window the requested content lock could not be granted? Ad Franse nexusdb.public.support 12 7th August 2014 06:35 PM
New user...How to view content of nx1 files? gorlaz nexusdb.public.support 11 15th March 2011 08:12 PM
Web Application - Support Content-Encoding: gzip jprenou nexusdb.public.discussions 3 9th November 2010 05:11 AM
How to avoid the window the requested content lock could not be granted? Ad Franse Binaries 0 29th June 2009 06:08 PM
Transactions and locks ron schultz nexusdb.public.support 0 17th April 2004 09:59 AM


All times are GMT +11. The time now is 11:26 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.