vamossagar12 commented on code in PR #13801: URL: https://github.com/apache/kafka/pull/13801#discussion_r1240598727
########## connect/runtime/src/main/java/org/apache/kafka/connect/storage/ConnectorOffsetBackingStore.java: ########## @@ -279,10 +284,61 @@ public Future<Void> set(Map<ByteBuffer, ByteBuffer> values, Callback<Void> callb throw new IllegalStateException("At least one non-null offset store must be provided"); } + boolean containsTombstones = values.containsValue(null); + + // If there are tombstone offsets, then the failure to write to secondary store will + // not be ignored. Also, for tombstone records, we first write to secondary store and + // then to primary stores. + if (secondaryStore != null && containsTombstones) { + AtomicReference<Throwable> secondaryStoreTombstoneWriteError = new AtomicReference<>(); + Future<Void> secondaryWriteFuture = secondaryStore.set(values, (secondaryWriteError, ignored) -> { + try (LoggingContext context = loggingContext()) { + if (secondaryWriteError != null) { + log.warn("Failed to write offsets with tombstone records to secondary backing store", secondaryWriteError); + secondaryStoreTombstoneWriteError.compareAndSet(null, secondaryWriteError); + } else { + log.debug("Successfully flushed tombstone offsets to secondary backing store"); + } + } + }); Review Comment: I tried something like this => ``` FutureCallback<Void> failedWriteCallback = new FutureCallback<>(callback); secondaryStore.set(values, failedWriteCallback); /* Future<Void> secondaryWriteFuture = secondaryStore.set(values, (secondaryWriteError, ignored) -> { try (LoggingContext context = loggingContext()) { if (secondaryWriteError != null) { log.warn("Failed to write offsets with tombstone records to secondary backing store", secondaryWriteError); secondaryStoreTombstoneWriteError.compareAndSet(null, secondaryWriteError); } else { log.debug("Successfully flushed tombstone(s)-containing to secondary backing store"); } } }); */ try { if (exactlyOnce) { failedWriteCallback.get(); } else { failedWriteCallback.get(offsetFlushTimeoutMs, TimeUnit.MILLISECONDS); } ``` which does whatever we discussed above i.e the SetCallback, when it's `onComplete` is executed, executes the `onComplete` of the `FutureCallback` object which eventually executes the actual passed in `callback`. But, when the secondary write fails, we need to eventually return another `Future` object . Maybe I am still missing the point you are making here. We can sync up maybe on this. -- 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: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org