Search in sources :

Example 1 with CatchupPollingProcess

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));
}
Also used : TransactionFailureException(org.neo4j.kernel.api.exceptions.TransactionFailureException) CatchupPollingProcess(org.neo4j.causalclustering.catchup.tx.CatchupPollingProcess) Cluster(org.neo4j.causalclustering.discovery.Cluster) ReadReplicaGraphDatabase(org.neo4j.causalclustering.readreplica.ReadReplicaGraphDatabase) CoreGraphDatabase(org.neo4j.causalclustering.core.CoreGraphDatabase) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 CatchupPollingProcess (org.neo4j.causalclustering.catchup.tx.CatchupPollingProcess)1 CoreGraphDatabase (org.neo4j.causalclustering.core.CoreGraphDatabase)1 Cluster (org.neo4j.causalclustering.discovery.Cluster)1 ReadReplicaGraphDatabase (org.neo4j.causalclustering.readreplica.ReadReplicaGraphDatabase)1 TransactionFailureException (org.neo4j.kernel.api.exceptions.TransactionFailureException)1