PostgreSQL checkpoint migration and operations
For a new deployment, initialize the schema and start using the new checkpoint format. For existing 2.1.0.0 data, roll out the upgrade and switch after the old application instances leave. Keep the original schema, serializer, and business thread IDs.
Initialize and switch
- Connect the migration account to the target schema and initialize it as shown below. For an existing schema, back it up, rehearse on a copy, and allow for a lock window while history is backfilled. Use
CREATE_IF_NOT_EXISTSon existing tables.CREATE_OR_REPLACEdrops existing checkpoint tables. - After initializing a schema from the released version, new instances continue writing the old format during the compatibility period. Start the application with
CREATE_NONE. Use the old application to verify progress just saved by the new one, then finish upgrading all readers and writers. - Drain compatibility writes and archive jobs, and isolate old writers. Call
migrationSaver.activateCheckpointV1Writes()with the migration account, then restore traffic. The switch rejects future writes in the old format and keeps existing checkpoints readable.
var migrationSaver = PostgresSaver.builder()
.datasource(migrationDataSource)
.createOption(CreateOption.CREATE_IF_NOT_EXISTS)
.build();
After switching, resume an existing conversation and a paused approval, then enable large state options key by key. If two upgraded instances try to resume the same thread concurrently, one will be rejected. Retry with the same threadId once the active run finishes.
Keep history and reclaim payload storage
Follow the checkpoint retention guide to set your policy for active history and archives. Review candidates and recovery metrics before turning on deletion. Pruning preserves child checkpoints referenced by a retained parent. The collector checks for references and active readers again before deleting a payload.
Recovery and collection metrics
Pass your application's MeterRegistry to the blob store.
| Metric | How to use it |
|---|---|
spring.ai.alibaba.checkpoint.resume.blob.reads, spring.ai.alibaba.checkpoint.resume.blob.bytes | Verify cold recovery. Both should be zero when the resumed execution uses only small fields. |
spring.ai.alibaba.checkpoint.blob.gc.candidates, spring.ai.alibaba.checkpoint.blob.gc.candidate.bytes | Review the number and size of candidates during observation and estimate reclaimable space. |
spring.ai.alibaba.checkpoint.blob.gc.deleted, spring.ai.alibaba.checkpoint.blob.gc.deleted.bytes | Check that observation performs no deletions, and measure what is reclaimed after enabling deletion. |