dcapwell commented on code in PR #3842: URL: https://github.com/apache/cassandra/pull/3842#discussion_r1936381336
########## src/java/org/apache/cassandra/service/accord/AccordService.java: ########## @@ -377,24 +371,33 @@ public synchronized void startup() node.commandStores().restoreShardStateUnsafe(topology -> configService.reportTopology(topology, true, true)); configService.start(); - long minEpoch = fetchMinEpoch(); - if (minEpoch >= 0) + try { - for (long epoch = minEpoch; epoch <= metadata.epoch.getEpoch(); epoch++) - node.configService().fetchTopologyForEpoch(epoch); + // Fetch topologies up to current + List<Topology> topologies = fetchTopologies(0, metadata); + for (Topology topology : topologies) + configService.reportTopology(topology); - try - { - epochReady(metadata.epoch).get(DatabaseDescriptor.getTransactionTimeout(MILLISECONDS), MILLISECONDS); - } - catch (InterruptedException e) - { - throw new UncheckedInterruptedException(e); - } - catch (ExecutionException | TimeoutException e) + ClusterMetadataService.instance().log().addListener(configService.listener); + ClusterMetadata next = ClusterMetadata.current(); + + // if metadata was updated before we were able to add a listener, fetch remaining topologies + if (metadata != next) Review Comment: I can't speak for TCM, but in Accord this pattern has caused bugs... refactors break assumptions, and you have no clean way to find all the places where your refactor would break things... we had a bug a long time ago when we would do `if (cmd.txnId() == txnId)` and had to switch to `if (cmd.txnId().equals(txnId))`... a refactor broke the assumption that the objects won't be recreated, which then caused that condition to be `false` and do the wrong thing... -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org For additional commands, e-mail: pr-h...@cassandra.apache.org