Browse Source

Added another repository deadlock test while investigating a deadlock case

split-DB
catbref 4 years ago
parent
commit
0b5e5832c4
  1. 22
      src/test/java/org/qortal/test/RepositoryTests.java

22
src/test/java/org/qortal/test/RepositoryTests.java

@ -95,6 +95,28 @@ public class RepositoryTests extends Common {
} }
} }
@Test
public void testUpdateReadDeadlock() throws DataException {
// Open connection 1
try (final Repository repository1 = RepositoryManager.getRepository()) {
// Mint blocks so we have data (online account signatures) to work with
for (int i = 0; i < 10; ++i)
BlockUtils.mintBlock(repository1);
// Perform database 'update', but don't commit at this stage
repository1.getBlockRepository().trimOldOnlineAccountsSignatures(System.currentTimeMillis());
// Open connection 2
try (final Repository repository2 = RepositoryManager.getRepository()) {
// Perform database read on same blocks - this should not deadlock
repository2.getBlockRepository().getTimestampFromHeight(5);
}
// Save updates - this should not deadlock
repository1.saveChanges();
}
}
/** Check that the <i>sub-query</i> used to fetch highest block height is optimized by HSQLDB. */ /** Check that the <i>sub-query</i> used to fetch highest block height is optimized by HSQLDB. */
@Test @Test
public void testBlockHeightSpeed() throws DataException, SQLException { public void testBlockHeightSpeed() throws DataException, SQLException {

Loading…
Cancel
Save