Skip to main content
Version: 2.1.x

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​

  1. 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_EXISTS on existing tables. CREATE_OR_REPLACE drops existing checkpoint tables.
  2. 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.
  3. 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.

MetricHow to use it
spring.ai.alibaba.checkpoint.resume.blob.reads, spring.ai.alibaba.checkpoint.resume.blob.bytesVerify 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.bytesReview 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.bytesCheck that observation performs no deletions, and measure what is reclaimed after enabling deletion.

Spring AI Alibaba 开源项目基于 Spring AI 构建,是阿里云通义系列模型及服务在 Java AI 应用开发领域的最佳实践,提供高层次的 AI API 抽象与云原生基础设施集成方案,帮助开发者快速构建 AI 应用。

浙ICP备2021005855号-33