Skip to content

Commit

Permalink
added additional logging to consistency check
Browse files Browse the repository at this point in the history
  • Loading branch information
bilal-shehata committed Jul 20, 2023
1 parent fdcf2ae commit d2ce9ec
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,18 @@ public void write(Connection main) {

@Override
public boolean isConsistent(Supplier<Connection> replicaSupplier) {
return cluster.getReplicas(replicaSupplier)
.stream()
Collection<Database> replicas = cluster.getReplicas(replicaSupplier);
logger.info("Checking consistency for " + replicas.size() + " replicas.");

return replicas.stream()
.allMatch(replica -> {
try (LazyConnectionSupplier connectionSupplier = new LazyConnectionSupplier(replica.getConnectionSupplier())) {
return replicaConsistency.isConsistent(connectionSupplier);
} catch (ReadReplicaConnectionCreationException exception) {
logger.warn("ReadReplicaConnectionCreationException occurred during consistency checking. It is likely that replica is the process of scaling, replica id: " + replica.getId(), exception);
logger.warn(
"ReadReplicaConnectionCreationException occurred during consistency checking. It is likely that replica is the process of scaling, replica id: " + replica.getId(),
exception
);
return true;
} catch (SQLException exception) {
throw new ConnectionCouldNotBeClosedException(exception);
Expand All @@ -79,7 +84,7 @@ private LazyConnectionSupplier(Supplier<Connection> supplier) {
* The initial implementation of AuroraMultiReplicaConsistency was buggy. The implementation took the
* connection management responsibility from ReplicaConsistency. The current implementation fixes the issue
* by allowing ReplicaConsistency implementation to take full responsibility for the connection lifecycle.
*
* <p>
* Unfortunately, the existing implementations of ReplicaConsistency may rely on the bug (for example some
* implementations in our product rely on it). To make it backwards compatible (behavioural compatibility),
* LazyConnectionSupplier closes the connection if ReplicaConsistency doesn't do that.
Expand Down

0 comments on commit d2ce9ec

Please sign in to comment.