From: Thompson, B. B. <BRY...@sa...> - 2006-04-04 15:00:51
|
Kevin, If one transaction is suspended and another waits on it then there is no deadlock -- assuming that the suspended transaction will eventually release its locks. If the suspended transaction never results then this is still not a deadlock. Transactions are required to run and terminate and a suspended transaction which does not resume is violating that requirement. -bryan -----Original Message----- From: jdb...@li... To: JDBM Developer listserv Sent: 4/4/2006 10:47 AM Subject: re[2]: [Jdbm-developer] A preview of how thread local works out... Bryan- The issue you describe only arises if the developer is using 2PL, and even then deadlock detection should kick in and blow one of the transactions. My opinion on this is that if a developer is using suspend and resume, then they are doing it in the context of a much larger synchronization/concurrency implementation (e.g. Alex's processing pools, non blocking IO, etc...). As for having a library to support this kind of concurrency, I think that this is a fantastic idea - but for a different OSS project. JDBM's primary responsibility in this arena is to provide a mechansim to allow developers to interact with the database in this manner - and I'm pretty sure that suspend and resume is really all that's needed to do that. - K > Kevin, This looks simple enough. However, leaving a tx paused can cause grief since any tx that blocks on the paused tx will never run. This will make the actual use of start/suspend/resume much more complex. Perhaps we should create some utility classes, e.g., thread pools, oriented at facilitating such concurrency processing? We could also use a timeout on suspend that started ticking once another tx blocks on a suspended tx -- otherwise the active threads could become easily absorbed. -bryan -----Original Message----- From: <mailto:jdb...@li...> jdb...@li... <mailto:jdb...@li...> [mailto:jdb...@li...] On Behalf Of Kevin Day Sent: Tuesday, April 04, 2006 1:57 AM To: JDBM Developer listserv Subject: [Jdbm-developer] A preview of how thread local works out... I put together some sample code to show the impact of the threadlocal decision, and wanted to share it... I'm quite happy with how it works out... Cheers! - K package jdbm2test; /** * A simple example to show how an application would interact with the record manager * @author kevin * */ public class BasicUsage { public BasicUsage() { } public static void main(String[] args) { // TODO: Replace the TestDB calls with a record manager provider of some sort TestDB db = TestDB.getCleanDB(); RecordManager recman = db.recMgr; recman.startNewTransaction(); int recid1 = recman.insert(new byte[]{1, 2, 3, 4, 5}); int recid2 = recman.insert(new byte[]{2, 3, 4, 5, 6}); recman.commitTransaction(); recman.startNewTransaction(); byte[] retrieved1 = recman.fetch(recid1).data; byte[] retrieved2 = recman.fetch(recid2).data; retrieved1[3] = retrieved2[3]; recman.update(recid1, retrieved1); recman.commitTransaction(); recman.startNewTransaction(); int recid3 = recman.insert(new byte[]{3, 4, 5, 6, 7}); Transaction suspendedTx = recman.suspendTransaction(); recman.startNewTransaction(); int recid4 = recman.insert(new byte[]{4, 5, 6, 7, 8}); Row r1 = recman.fetch(recid3); // note : this will return null System.out.println("r1 is " + r1); recman.commitTransaction(); recman.resumeTransaction(suspendedTx); Row r2 = recman.fetch(recid3); // note: this will return a valid value System.out.println("r2 is " + r2.data[0] + ", " + r2.data[1] + "..."); recman.commitTransaction(); } } ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! <http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=12164 2> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 _______________________________________________ Jdbm-developer mailing list <mailto:Jdb...@li...> Jdb...@li... <https://lists.sourceforge.net/lists/listinfo/jdbm-developer> https://lists.sourceforge.net/lists/listinfo/jdbm-developer ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! <http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=12164 2> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 _______________________________________________ Jdbm-developer mailing list <mailto:Jdb...@li...> Jdb...@li... <https://lists.sourceforge.net/lists/listinfo/jdbm-developer> https://lists.sourceforge.net/lists/listinfo/jdbm-developer < ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 _______________________________________________ Jdbm-developer mailing list Jdb...@li... https://lists.sourceforge.net/lists/listinfo/jdbm-developer |