Skip to content

Commit 6910016

Browse files
committed
Adjust TestQueryForUpdate for Yugabyte - use markAsDirty
To see if the update has an impact on the 2nd thread waiting
1 parent 5f8a3c0 commit 6910016

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

ebean-test/src/test/java/org/tests/basic/TestQueryForUpdate.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,22 @@ public void testConcurrentForUpdate() throws InterruptedException {
9797

9898
ResetBasicData.reset();
9999

100+
Database db = DB.getDefault();
100101
Thread t1 = new Thread() {
101102
@Override
102103
public void run() {
103-
try (final Transaction transaction = DB.createTransaction()) {
104+
try (final Transaction transaction = db.createTransaction()) {
104105
log.info("Thread: before find");
105-
DB.find(Customer.class)
106+
List<Customer> list = DB.find(Customer.class)
106107
.usingTransaction(transaction)
107108
.forUpdate()
108-
// .orderBy().desc("1") // this would help by the locks in DB2
109+
// .orderBy().desc("1") // this would help by the locks in DB2
109110
.findList();
110111

112+
Customer first = list.get(0);
113+
db.markAsDirty(first);
114+
db.save(first, transaction);
115+
111116
log.info("Thread: after find");
112117
try {
113118
Thread.sleep(3000);
@@ -124,7 +129,7 @@ public void run() {
124129
Thread.sleep(300);
125130

126131
long start = System.currentTimeMillis();
127-
try (final Transaction transaction = DB.beginTransaction()) {
132+
try (final Transaction transaction = db.beginTransaction()) {
128133
if (isH2()) {
129134
DB.sqlUpdate("SET LOCK_TIMEOUT 5000").execute();
130135
}

0 commit comments

Comments
 (0)