[FLINK-40302][state] Do not let native savepoints block periodic materialization - #28891
Open
wonyongChoi05 wants to merge 3 commits into
Open
[FLINK-40302][state] Do not let native savepoints block periodic materialization#28891wonyongChoi05 wants to merge 3 commits into
wonyongChoi05 wants to merge 3 commits into
Conversation
Collaborator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the purpose of the change
Fixes FLINK-40302: with the changelog state backend enabled, taking a single intermediate NATIVE-format savepoint permanently stops periodic materialization for the rest of the job's lifetime.
ChangelogKeyedStateBackend#nativeSavepoint()consumes a materialization ID (materializedId++) and registers it inmaterializationIdByCheckpointId, expecting a laternotifyCheckpointComplete()to confirm it. However, theCheckpointCoordinatoronly sends acknowledge messages for savepoints that are synchronous (FLIP-203) — intermediate savepoints are never notified. Since the savepoint succeeded,lastFailedMaterializationIdis not advanced either. The guard ininitMaterialization()therefore stays true forever, every subsequent periodic materialization is skipped ("materialization:{} not confirmed or failed or cancelled, skip trigger new one."), the delegated RocksDB backend is never flushed again, and the changelog grows unboundedly until the job is restarted.
The root cause is that the guard uses
materializedId - 1as a proxy for "the last triggered materialization", whilenativeSavepoint()consumes IDs from the same counter without triggering a materialization, breaking the proxy.Brief change log
lastTriggeredMaterializationIdinChangelogKeyedStateBackend, set wheninitMaterialization()actually triggers a materialization and reset incompleteRestore().initMaterialization()now compareslastConfirmedMaterializationId/lastFailedMaterializationIdagainstlastTriggeredMaterializationIdinstead ofmaterializedId - 1.nativeSavepoint()is unchanged: it still consumes a unique ID and registers it for confirmation, so synchronous savepoints keep notifying the delegated backend.Verifying this change
This change added tests and can be verified as follows:
Added
ChangelogKeyedStateBackendTest#testInitMaterializationAfterAbortedNativeSavepoint: takes a NATIVE-format savepoint without deliveringnotifyCheckpointComplete(i.e. an intermediate savepoint), then asserts thatinitMaterialization()still triggers. Without this fix it returnsOptional.empty(); with the fix it triggers as expected.Does this pull request potentially affect one of the following parts:
@Public(Evolving): noDocumentation