1919
2020public class TestQueryForUpdate extends BaseTestCase {
2121
22- private static final Logger log = LoggerFactory .getLogger ("testConcurrentForUpdate" );
23- private static final Logger log2 = LoggerFactory .getLogger ("repeatableRead" );
22+ private static final Logger log = LoggerFactory .getLogger (TestQueryForUpdate .class );
2423
2524 @ Test
2625 public void testForUpdate () {
@@ -45,7 +44,7 @@ public void testForUpdate() {
4544 }
4645 }
4746
48- // Nah, nothing to do with repeatable read here
47+ // Nah, nothing to do with repeatable read here
4948 @ ForPlatform (Platform .YUGABYTE )
5049 @ Test
5150 void concurrentForUpdate () throws InterruptedException {
@@ -56,19 +55,19 @@ void concurrentForUpdate() throws InterruptedException {
5655 @ Override
5756 public void run () {
5857 try (final Transaction transaction = db .createTransaction (TxIsolation .REPEATABLE_READ )) {
59- log2 .info ("(REPEATABLE_READ) Thread: before find" );
58+ log .info ("(REPEATABLE_READ) Thread: before find" );
6059 List <Country > list = DB .find (Country .class )
6160 .usingTransaction (transaction )
6261 .forUpdate ()
6362 .findList ();
6463
6564 try {
66- log2 .info ("(REPEATABLE_READ) Thread: after find - size:{}, hold locks for some time" , list .size ());
65+ log .info ("(REPEATABLE_READ) Thread: after find - size:{}, hold locks for some time" , list .size ());
6766 Thread .sleep (500 );
6867 } catch (InterruptedException e ) {
6968 throw new RuntimeException (e );
7069 }
71- log2 .info ("(REPEATABLE_READ) Thread: done, release locks" );
70+ log .info ("(REPEATABLE_READ) Thread: done, release locks" );
7271 }
7372 }
7473 };
@@ -78,13 +77,13 @@ public void run() {
7877
7978 long start = System .currentTimeMillis ();
8079 try (final Transaction transaction = db .createTransaction (TxIsolation .REPEATABLE_READ )) {
81- log2 .info ("(REPEATABLE_READ) Main: before find, should wait for locks to be released..." );
80+ log .info ("(REPEATABLE_READ) Main: before find, should wait for locks to be released..." );
8281 DB .find (Country .class )
8382 .usingTransaction (transaction )
8483 .forUpdate ()
8584 .findList ();
8685
87- log2 .info ("(REPEATABLE_READ) Main: complete" );
86+ log .info ("(REPEATABLE_READ) Main: complete" );
8887 }
8988
9089 long exeMillis = System .currentTimeMillis () - start ;
@@ -103,14 +102,8 @@ public void testConcurrentForUpdate() throws InterruptedException {
103102 List <Customer > list = DB .find (Customer .class )
104103 .usingTransaction (transaction )
105104 .forUpdate ()
106- // .orderBy().desc("1") // this would help by the locks in DB2
107105 .findList ();
108106
109- // yugabyte: performing an update does not change the behaviour
110- Customer first = list .get (0 );
111- db .markAsDirty (first );
112- db .save (first , transaction );
113-
114107 try {
115108 log .info ("Thread: after find - rows locked:{}, hold for 700ms" , list .size ());
116109 Thread .sleep (600 ); // 3000
0 commit comments