Skip to main content
Version: 2.1.x

MongoDB replica set checkpoints

If your application already uses a MongoDB replica set, you can save conversation and workflow progress in the same database. Managed checkpoints have been validated on a MongoDB 7.0 replica set.

New deployments​

Connect using a replica set name and multiple member addresses. Use the same MongoClient instance and database for the saver, the blob store, and parent and child graphs you need to fork together. Across application instances, keep the serializer and blob namespace consistent. A new database uses the new checkpoint format by default.

import com.alibaba.cloud.ai.graph.checkpoint.savers.mongo.MongoCheckpointBlobStore;
import com.alibaba.cloud.ai.graph.checkpoint.savers.mongo.MongoSaver;

var saver = MongoSaver.builder()
.client(mongoClient)
.databaseName("check_point_db")
.build();
var blobs = new MongoCheckpointBlobStore(mongoClient, "check_point_db", "support-workflow");

Register saver with the graph. For extracted text or other values that could exceed MongoDB's document size limit, follow the large state guide to attach blobs and offload that key.

Upgrade existing checkpoints​

  1. Back up the checkpoint database and reserve space for a copy of old history. Keep the original database and serializer, and make sure the migration account can create collections and indexes.
  2. Follow the rolling upgrade guide to upgrade all instances. Drain old runs, writes, and archive jobs, then call activateManagedCheckpointWrites(). Restart the application or rebuild the saver and recompile the graph.
  3. Verify recovery and history with the original threadId. The upgraded saver picks up identifiable old records, preserving IDs and order. Old archives whose thread mappings are missing and any custom blob storage need separate migration.

Blob garbage collection defaults to observation only. See retention, collection, and monitoring.

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

浙ICP备2021005855号-33