Re: Accessing the current SQL connection in agent execution

Sasa Bojanic <[email protected]> Tue, 30 Oct 2007 15:20:00 +0100
Newsgroups gmane.comp.java.enhydra.shark
Message-ID <[email protected]>
This is a multi-part message in MIME format...

------------=_1193754166-10408-10
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Well, believe me, this code insures the uniqueness of Ids across VMs. 
This code, along with DODS' ObjectId allocator (which is written in a 
similar way) are the reason why shark can be used in cluster scenario.

If you analyze it, you'll see that we first read the current Id value 
from the database, and then try to put the new value which is greater 
than the current one for the specified cache size. If we fail, it means 
another thread from the same or from some other VM changed the value in 
DB meanwhile, and we got an exception from DODS because DODS recognizes 
that the version column of the row in a database is not appropriate. 
E.g. if some other thread changed the value meanwhile, it also changed 
the version column, and our UPDATE command specifies the old version and 
fails. If we fail, we try to repeat read/write for 50 times which should 
really be enough to succeed at last.

Greetings,
Sasa.

[email protected] wrote:
> Hi Sasa. Thanks a lot for your prompt response.
> Since I have to retain the same DBTransaction throughout the whole agent lifespan (in case of rollbacks) I can not use DODSUtilities.getNext().
> I peeked in its source code, though.
> You wrote: "The Id you get is synchronized on a database, so you can safely use it from several VMs"
> At a first glance I didn't find the code to grant this. 
> The method is static and synchronized, and it tries 50 times in case an exception is thrown, but it doesn't lock the record, so an other process from another VM accessing the same data might tamper with the table and get away with it.
> Did I miss something?
>
> T.I.A.,
> Manrico
>
> PS:
> At the moment I'm trying to hack into the DO/DOI/Query and DataStruct classes to get the underlying Connection object and use a SELECT ... FOR UPDATE as we used to in the old days :-)
>
>
>   
> ------------------------------------------------------------------------
>
>
> --
> You receive this message as a subscriber of the [email protected] mailing list.
> To unsubscribe: mailto:[email protected]
> For general help: mailto:[email protected]?subject=help
> ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
>   



------------=_1193754166-10408-10
Content-Type: text/plain; name="message-footer.txt"
Content-Disposition: inline; filename="message-footer.txt"
Content-Transfer-Encoding: 8bit


--
You receive this message as a subscriber of the [email protected] mailing list.
To unsubscribe: mailto:[email protected]
For general help: mailto:[email protected]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws

------------=_1193754166-10408-10--