sunshone commented on code in PR #13693:
URL: https://github.com/apache/gluten/pull/13693#discussion_r4691113286
##########
gluten-flink/runtime/src/main/java/org/apache/gluten/table/runtime/operators/GlutenOneInputOperator.java:
##########
@@ -336,11 +352,37 @@ public void snapshotState(StateSnapshotContext context)
throws Exception {
}
protected void snapshotNativeState(StateSnapshotContext context) throws
Exception {
- task.snapshotState(context.getCheckpointId());
+ // The native snapshot returns the checkpoint records of the stateful
+ // operators (typed keyed backends); persist them in the operator state
+ // so a restore can feed them back (design D4 of the rank task). Empty
+ // for operators without native state, so the path is transparent to
+ // every other user of this class.
+ byte[][] checkpointRecords = task.snapshotState(context.getCheckpointId());
+ checkpointState.clear();
+ for (byte[] checkpointRecord : checkpointRecords) {
+ checkpointState.add(checkpointRecord);
+ }
}
@Override
public void initializeState(StateInitializationContext context) throws
Exception {
+ // Declare the checkpoint-record store and collect the restored records
+ // before the native state initialization consumes them (the
+ // GlutenSourceFunction pattern).
+ checkpointState =
+ context
+ .getOperatorStateStore()
+ .getListState(
Review Comment:
@ggjh-159 Agreed on the interim. The state is now registered with
getUnionListState at this site and at the source and file-writer persistence
sites; under union redistribution every subtask receives every writer's shard
at restore, and the native backend picks its own key groups out of each shard
(velox-side: a stream with no overlap is skipped instead of rejected, since
under union it is an expected delivery). Restore correctness across rescales is
pinned by the stateful suite (the rescale and four-way-shard tests) and by the
checkpoint round-trip suite. The keyed-state integration - a KeyedStateBackend
implementation over the native backend, with Flink owning the key-group
sharding, rescaling and savepoint semantics - is documented as the follow-up in
the code comment at this site and in the PR description. On the
parallelism-change guard: with union distribution the restore completes for any
rescale by construction, so a fail-loud guard would reject correct restores; if
you pr
efer a guard regardless, it can be added with the follow-up work.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]