use of org.neo4j.causalclustering.catchup.tx.CatchupPollingProcess in project neo4j by neo4j.
the class ReadReplicaReplicationIT method transactionsShouldNotAppearOnTheReadReplicaWhilePollingIsPaused.
@Test
public void transactionsShouldNotAppearOnTheReadReplicaWhilePollingIsPaused() throws Throwable {
// given
Cluster cluster = clusterRule.startCluster();
ReadReplicaGraphDatabase readReplicaGraphDatabase = cluster.findAnyReadReplica().database();
CatchupPollingProcess pollingClient = readReplicaGraphDatabase.getDependencyResolver().resolveDependency(CatchupPollingProcess.class);
pollingClient.stop();
cluster.coreTx((coreGraphDatabase, transaction) -> {
coreGraphDatabase.createNode();
transaction.success();
});
CoreGraphDatabase leaderDatabase = cluster.awaitLeader().database();
long transactionVisibleOnLeader = transactionIdTracker(leaderDatabase).newestEncounteredTxId();
// when the poller is paused, transaction doesn't make it to the read replica
try {
transactionIdTracker(readReplicaGraphDatabase).awaitUpToDate(transactionVisibleOnLeader, ofSeconds(3));
fail("should have thrown exception");
} catch (TransactionFailureException e) {
// expected timeout
}
// when the poller is resumed, it does make it to the read replica
pollingClient.start();
transactionIdTracker(readReplicaGraphDatabase).awaitUpToDate(transactionVisibleOnLeader, ofSeconds(3));
}
Aggregations