|
Werner,
Before we indulge into the time out issues, I would like your confirmation whether this is an expected behavior, wherein an object being dbLocked also gets the read lock on it.
If the output of the sample code below is as the expected behavior, I wouldn’t like to have read locks when I DbLock my object, since the performance of my application is degrading a lot.
Regarding the table type, I’m using innodb tables of mysql.
Here’s the Log of my test case: Setting data in DB Setting data in DB -- Done Starting Writer thread..... WriterThread -- Before db locking WriterThread -- After db locking WriterThread -- Before updating name ReaderThread -- Starting reader thread..... ReaderThread -- Trying to read..... WriterThread -- After updating name WriterThread -- Commiting & Closing transaction ReaderThread -- Read: [Rocket(WriterThread changed Name), with Fuel(Solid Ammonia)] ReaderThread -- Trying to read..... ReaderThread -- Read: [Rocket(WriterThread changed Name), with Fuel(Solid Ammonia)] ReaderThread -- Trying to read..... ReaderThread -- Read: [Rocket(WriterThread changed Name), with Fuel(Solid Ammonia)] ReaderThread -- Trying to read..... ReaderThread -- Read: [Rocket(WriterThread changed Name), with Fuel(Solid Ammonia)] ReaderThread -- Trying to read..... ReaderThread -- Read: [Rocket(WriterThread changed Name), with Fuel(Solid Ammonia)] WriterThread -- Clearing the DB ReaderThread -- Trying to read..... ReaderThread -- Read: [Rocket(WriterThread changed Name), with Fuel(Solid Ammonia)] WriterThread -- Clearing the DB... finished ReaderThread -- Stopped reading.
The run method of Writer thread:
public void run() { try { System.out.println("Starting Writer thread.....");
System.out.println("WriterThread -- Before db locking");
Rocket rocket = rocket_DAO.retrieveByName( PRITHVI, transaction, Transaction.DbLocked); System.out.println("WriterThread -- After db locking"); System.out.println("WriterThread -- Before updating name"); sleep(3000); rocket.setRocketName("WriterThread changed Name"); System.out.println("WriterThread -- After updating name"); sleep(10000); transaction.commitAndClose(); System.out.println( "WriterThread -- Commiting & Closing transaction"); sleep(5000); System.out.println("WriterThread -- Clearing the DB"); deleteDB(); System.out.println("WriterThread -- Clearing the DB... finished"); } catch (Exception e) { e.printStackTrace(); } }
The run method of the Writer Thread:
public void run() { try { System.out.println("ReaderThread -- Starting reader thread.....");
while (read) { System.out.println("ReaderThread -- Trying to read.....");
ArrayList rockets = rocket_DAO.retrieveAllRockets(txn, Transaction.ReadOnly); System.out.println("ReaderThread -- Read: " + rockets); sleep(1000); }
System.out.println("ReaderThread -- Stopped reading."); } catch (Exception e) { e.printStackTrace(); } }
Thanks & Regards, Jimmy -----Original Message-----
Jimmy,
|
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-user
