XComp commented on a change in pull request #18901: URL: https://github.com/apache/flink/pull/18901#discussion_r814672839
########## File path: flink-kubernetes/src/main/java/org/apache/flink/kubernetes/highavailability/KubernetesStateHandleStore.java ########## @@ -132,31 +197,27 @@ public KubernetesStateHandleStore( final RetrievableStateHandle<T> storeHandle = storage.store(state); - final byte[] serializedStoreHandle = serializeOrDiscard(storeHandle); + final byte[] serializedStoreHandle = + serializeOrDiscard(new StateHandleWithDeleteMarker<>(storeHandle)); // initialize flag to serve the failure case boolean discardState = true; try { // a successful operation will result in the state not being discarded discardState = - !kubeClient - .checkAndUpdateConfigMap( - configMapName, - c -> { - if (isValidOperation(c)) { - if (!c.getData().containsKey(key)) { - c.getData() - .put( - key, - encodeStateHandle( - serializedStoreHandle)); - return Optional.of(c); - } else { - throw new CompletionException( - getKeyAlreadyExistException(key)); - } + !updateConfigMap( + configMap -> { + if (!configMap.getData().containsKey(key)) { + configMap + .getData() + .put( + key, + encodeStateHandle( + serializedStoreHandle)); + return Optional.of(configMap); } - return Optional.empty(); + throw new CompletionException( Review comment: Going through the code path again - you're right. But I handled it differently in the `ZooKeeperStateHandleStore`. I will update that in the corresponding PR to also fail in that case to have both stores behave consistently. -- 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: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org