ibessonov commented on code in PR #4632: URL: https://github.com/apache/ignite-3/pull/4632#discussion_r1816521297
########## modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/server/AbstractKeyValueStorage.java: ########## @@ -224,34 +214,24 @@ public long getCompactionRevision() { } @Override - public void startCompaction(long compactionRevision) { + public void updateCompactionRevision(long compactionRevision, KeyValueUpdateContext context) { assert compactionRevision >= 0 : compactionRevision; rwLock.writeLock().lock(); try { assertCompactionRevisionLessThanCurrent(compactionRevision, rev); + saveCompactionRevision(compactionRevision, context); + if (isInRecoveryState()) { - this.compactionRevision = compactionRevision; + setCompactionRevision(compactionRevision); Review Comment: I think this step can be done when we start compaction after recovery. So the real `if (isInRecoveryState()) {` here branch should be a no-op. ########## modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/server/AbstractKeyValueStorage.java: ########## @@ -334,18 +314,13 @@ public void watchExact(byte[] key, long rev, WatchListener listener) { } @Override - public CompletableFuture<Void> readOperationsFuture(long compactionRevisionExcluded) { - return readOperationForCompactionTracker.collect(compactionRevisionExcluded); - } - - @Override - public void registerCompactionListener(CompactionListener listener) { - compactionListeners.add(listener); + public void registerCompactionRevisionUpdateListener(CompactionRevisionUpdateListener listener) { Review Comment: Why don't you reuse `OnRevisionAppliedCallback`? It has a weird name, I get it, but it's a good place. There's no need for an additional list of listeners. Or am I wrong? ########## modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/server/AbstractKeyValueStorage.java: ########## @@ -224,34 +214,24 @@ public long getCompactionRevision() { } @Override - public void startCompaction(long compactionRevision) { + public void updateCompactionRevision(long compactionRevision, KeyValueUpdateContext context) { assert compactionRevision >= 0 : compactionRevision; rwLock.writeLock().lock(); try { assertCompactionRevisionLessThanCurrent(compactionRevision, rev); + saveCompactionRevision(compactionRevision, context); + if (isInRecoveryState()) { - this.compactionRevision = compactionRevision; + setCompactionRevision(compactionRevision); } else { - watchProcessor - .addTaskToWatchEventQueue(() -> setCompactionRevision(compactionRevision)) - .thenComposeAsync(unused -> readOperationsFuture(compactionRevision), compactionExecutor) - .thenRunAsync(() -> compact(compactionRevision), compactionExecutor) - .whenCompleteAsync((unused, throwable) -> { - if (throwable == null) { - log.info("Metastore compaction completed successfully: [compactionRevision={}]", compactionRevision); - } else { - log.error( - "Metastore compaction failed: [compactionRevision={}]", - unwrapCause(throwable), - compactionRevision - ); - } - - notifyCompleteCompactionLocally(this.compactionRevision, throwable); - }, compactionExecutor); + watchProcessor.addTaskToWatchEventQueue(() -> { Review Comment: I think we should use something less abstract, like "onCompactionSomething". Passing an arbitrary closure is a road to abuse. People will start doing all sorts of bad things. -- 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: notifications-unsubscr...@ignite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org