belliottsmith commented on code in PR #3823: URL: https://github.com/apache/cassandra/pull/3823#discussion_r1939190875
########## src/java/org/apache/cassandra/service/accord/AccordCommandStore.java: ########## @@ -505,32 +507,27 @@ else if (!CommandsForKey.managesExecution(txnId) && command.hasBeen(PreCommitted } @Override - public void load(Command command, OnDone onDone) + public AsyncChain<Void> load(TxnId txnId, Supplier<Command> supplier) { - store.execute(context(command, SYNC), safeStore -> loadInternal(command, safeStore)) - .begin((unused, throwable) -> { - if (throwable != null) - onDone.failure(throwable); - else - onDone.success(); - }); + if (store.caches.commands().isReferenced(txnId)) + return AsyncResults.SUCCESS_NULL; + + Command command = supplier.get(); + return store.submit(context(command, SYNC), + safeStore -> loadInternal(command, safeStore)) + .beginAsResult() + .flatMap(this::apply); } - @Override - public void apply(Command command, OnDone onDone) + public AsyncResult<Void> apply(Command command) { PreLoadContext context = context(command, SYNC); - store.execute(context, safeStore -> { + return store.execute(context, safeStore -> { applyWrites(command.txnId(), safeStore, (safeCommand, cmd) -> { Commands.applyWrites(safeStore, context, cmd).begin(store.agent); }); }) - .begin((unused, throwable) -> { - if (throwable != null) - onDone.failure(throwable); - else - onDone.success(); - }); + .beginAsResult(); Review Comment: Can we just return the `AsyncChain` here, and chain it onto the load before starting that? -- 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