/* Insert dups. */
insert(1, 1);
insert(1, 3);
/* getNextDup returns {1,3}. */
Transaction readerTxn = env.beginTransaction(null, txnConfig);
Cursor cursor = db.openCursor(readerTxn, null);
assertEquals(OperationStatus.SUCCESS, searchBoth(cursor, 1, 1));
status = cursor.getNextDup(key, data, null);
assertEquals(OperationStatus.SUCCESS, status);
assertEquals(1, IntegerBinding.entryToInt(key));
assertEquals(3, IntegerBinding.entryToInt(data));
/* Insert {1,2} in a writer thread. */
startInsert(1, 2);
/*
* If serializable, getNextDup should return {1,3} again; otherwise
* getNextDup should see {1,2}.
*/
assertEquals(OperationStatus.SUCCESS, searchBoth(cursor, 1, 1));
status = cursor.getNextDup(key, data, null);
assertEquals(OperationStatus.SUCCESS, status);
if (txnSerializable) {
assertEquals(1, IntegerBinding.entryToInt(key));
assertEquals(3, IntegerBinding.entryToInt(data));
} else {
assertEquals(1, IntegerBinding.entryToInt(key));
assertEquals(2, IntegerBinding.entryToInt(data));
}
/* Close reader to allow writer to finish. */
cursor.close();
readerTxn.commitNoSync();
waitForInsert();
/* getNextDup returns {1,2}. */
readerTxn = env.beginTransaction(null, txnConfig);
cursor = db.openCursor(readerTxn, null);
assertEquals(OperationStatus.SUCCESS, searchBoth(cursor, 1, 1));
status = cursor.getNextDup(key, data, null);
assertEquals(OperationStatus.SUCCESS, status);
assertEquals(1, IntegerBinding.entryToInt(key));
assertEquals(2, IntegerBinding.entryToInt(data));
cursor.close();
readerTxn.commit();
closeEnv();
}