[odb-users] Optimistic Concurrency : ROWVERSION exception

Chew Kok Keng ckokkeng at dso.org.sg
Mon May 20 09:43:53 EDT 2013


Hi Boris,

The change did solve the exception. However, another exception appeared. This time it appears at line 103 db->update (p2). Here's the printed output and the code snippet.

version after persist: 4003
process 1 version after load: 4003
process 2 version after load: 4003
process 1 version after update: 4004
process 2 version is out of date: 4003
process 2 version after reload: 4004
0 (24000): [Microsoft][SQL Server Native Client 10.0]Invalid cursor state

      try
      {
        db->update (p2);
      }
      catch (const object_changed&)
      {
        cout << "process 2 version is out of date: " << p2.version () << endl;

        // Reload the object and retry the operation. Note that the second
        // update call cannot throw object_changed since we reloaded the
        // object and are trying to update it in a single transaction.
        //
        db->reload (p2);

        cout << "process 2 version after reload: " << p2.version () << endl;

        p2.age (p2.age () + 1);
        db->update (p2); // Exception thrown here
      }


Regards,
Chew

________________________________________
From: Chew Kok Keng
Sent: Monday, May 20, 2013 10:03 AM
To: 'Boris Kolpackov'
Cc: 'odb-users at codesynthesis.com'
Subject: RE: [odb-users] Optimistic Concurrency : ROWVERSION exception

Hi Boris,

Pardon me for overlooking the odb-users mailing list. Appreciate your prompt reply. I'll try out as soon as I could.

Thanks,
Chew

-----Original Message-----
From: Boris Kolpackov [mailto:boris at codesynthesis.com]
Sent: Monday, May 20, 2013 8:29 AM
To: Chew Kok Keng
Cc: odb-users at codesynthesis.com
Subject: Re: [odb-users] Optimistic Concurrency : ROWVERSION exception

Hi Chew,

In the future please keep your replies CC'ed to the odb-users mailing list as discussed in the posting guidelines:

http://www.codesynthesis.com/support/posting-guidelines.xhtml


Chew Kok Keng <ckokkeng at dso.org.sg> writes:

> Here's the printed output
>
> version after persist: 2001
> process 1 version after load: 2001
> process 2 version after load: 2001
> process 1 version after update: 2002
> 0 (?????): result set expected from a statement with the OUTPUT clause

I did some testing and it appears we have a bug here. I have implemented a fix and it would be great if you could try it and confirm that it works for you as well. Here is what you will need to do:

1. Download statement.cxx from here:

   http://codesynthesis.com/~boris/tmp/odb/statement.cxx

2. Copy it to libodb-mssql-2.2.0/odb/mssql/ (override the old file).

3. Rebuild libodb-mssql.

4. Rebuild the optimistic example.

Once this is done, the example should work.

Boris



More information about the odb-users mailing list