[Bug]: StoreSessionStorage does not override readAll, so journal replay issues one get per segment
Describe the bug
JournalSessionLog.scan bulk-loads committed segments through AtomicSessionStorage.readAll, which was added in #3666. StoreSessionStorage, used by remote workspace stores such as JDBC/MySQL, Redis and MongoDB, does not override readAll. It therefore falls back to the default per-path implementation, and replay of a large journal becomes one BaseStore.get round-trip per commit segment.
A journal with 2,658 commit segments performs 2,658 JdbcStore.get calls. On a remote MySQL instance this takes tens of seconds.
To Reproduce
- Use a remote workspace store backed by
BaseStorewithsupportsAtomicSessionStorage() == true(for exampleJdbcStoreover MySQL). - Create a session journal with thousands of commit segments.
- Call
scan/readAfter, or restore the session. - Observe one
getper segment in the SQL log and replay latency that grows linearly with the segment count.
Expected behavior
StoreSessionStorage should implement readAll by fetching the requested journal objects in bulk, so journal replay uses a bounded number of store queries instead of one per segment.
Actual behavior
The default AtomicSessionStorage.readAll calls read(path) for every path, and StoreSessionStorage.read calls store.get(namespace, path) once per segment.
Environment
- AgentScope-Java Version: 2.1.0-SNAPSHOT
- Java Version: 17
- OS: Linux
- Store: remote JDBC/MySQL (the same path applies to Redis and MongoDB through
BaseStore)
Proposed fix
Add an opt-in BulkReadableStore extends BaseStore capability that declares getAll(namespace, keys), keeping BaseStore itself source-compatible:
InMemoryStore, JDBC, MySQL, PostgreSQL, MongoDB and Redis implementgetAll;- JDBC/MySQL/PostgreSQL use batched
IN (...)queries; MongoDB uses$in; Redis uses boundedHGETALLpipelines; StoreSessionStorage.readAlluses a directgetfor a single path,getAllfor multiple paths when the store is bulk-readable, and otherwise keeps the pagedsearchfallback with missing-path reads and per-key fallback when search is unsupported;- preserve the exact
readsemantics: missing paths are absent,version < 1throwsSessionLogException, values are base64-decoded, duplicate paths are deduplicated.
Tests cover parity with per-path read, more than 256 paths, fallback behavior, versions, missing paths, and the JDBC/MySQL/PostgreSQL/MongoDB/Redis implementations.
Implemented in #3996.