Configure storage backends in Cratis Chronicle Server
Configure the storage backend for Chronicle Server.
Storage types
Section titled “Storage types”| Type | Description |
|---|---|
MongoDB |
MongoDB (default) |
PostgreSql |
PostgreSQL |
MsSql |
Microsoft SQL Server |
Sqlite |
SQLite (embedded, file-based) |
InMemory |
In-memory (ephemeral, non-durable) |
MongoDB
Section titled “MongoDB”{ "storage": { "type": "MongoDB", "connectionDetails": "mongodb://localhost:27017" }}MongoDB connection pool
Section titled “MongoDB connection pool”Set pool options in storage.connectionDetails, for example:
{ "storage": { "type": "MongoDB", "connectionDetails": "mongodb://localhost:27017/?maxPoolSize=100&waitQueueTimeoutMS=120000&maxConnecting=2" }}The MongoDB driver defaults to a maximum pool size of 100 connections per server, a wait queue of 500 operations (five times the pool size), a wait timeout of 120000 ms, and 2 concurrent connection attempts per pool.
maxPoolSizelimits connections per server for each client. Increase it only when MongoDB has connection capacity for every silo and other application clients.waitQueueTimeoutMSbounds how long an operation waits for a connection. Increasing it tolerates longer bursts but does not add capacity. A full wait queue fails immediately withMongoWaitQueueFullException, which Chronicle treats as transient.maxConnectinglimits simultaneous connection establishment. Raising it can warm pools faster, but can also increase connection pressure during rollouts.
Registration admission is unlimited by default (observers.maxConcurrentRegistrations: 0). If you opt
into a positive cap, size the pool with headroom above that cap for appends, observer delivery and
background jobs. With a cap, registration concurrency across the cluster is approximately
maxConcurrentRegistrations × the number of silos; pools are per client and server, not shared across
silos. Account for all these pools against MongoDB’s connection limit. Increasing the registration
limit without pool headroom can make bursts worse. See Observers.
MongoDB health checks read the driver’s monitored cluster state without borrowing a pooled connection; pool saturation alone therefore does not make the MongoDB check unhealthy. This is not an active query or a guarantee that an application operation can immediately acquire a connection.
Index provisioning
Section titled “Index provisioning”Use --migrate-only to provision kernel-owned indexes before deployment and --verify-schema to check them without DDL. Both exit without starting the kernel. storage.schemaMode: Verify adds a warning-only MongoDB startup check of System/Default, its event-store level, and global encryption; it does not disable lazy runtime index creation. See MongoDB Index Operations for scope discovery, permissions, jobs routing, and exit codes.
Database-name prefix
Section titled “Database-name prefix”Set storage.databaseNamePrefix to isolate Chronicle’s databases on a shared MongoDB server:
{ "storage": { "type": "MongoDB", "connectionDetails": "mongodb://localhost:27017", "databaseNamePrefix": "staging_" }}The prefix is prepended verbatim to every database name, including the global chronicle+main database, event stores, namespaces, read models, Orleans reminders, cluster membership, and jobs. For example, chronicle+main becomes staging_chronicle+main, and Orders+es+Default becomes staging_Orders+es+Default. All nodes in a cluster must use the same prefix.
The default is an empty string: existing database names remain unchanged. Changing the prefix selects different databases; it does not rename or migrate existing data. The complete name, including the prefix, must satisfy MongoDB’s naming rules and 63-byte limit. Choose a short prefix without spaces or MongoDB’s forbidden characters.
For environment-variable configuration, use Cratis__Chronicle__Storage__DatabaseNamePrefix. The development-only kernel reset preserves the global cluster database and, when a prefix is set, drops only other databases starting with that exact, case-sensitive prefix. Use a unique prefix when sharing a server; a prefix is a naming boundary, not a substitute for database permissions.
System event store database name
Section titled “System event store database name”Chronicle keeps its own state, such as the System event log and the observers that run inside the kernel, in the System event store. On MongoDB, an event store’s databases are named after it: Orders+es, Orders+es+Default and Orders for its read models. The System event store is the exception. Some hosted offerings, such as MongoDB Atlas Flex, reserve a database named System, so its databases are named by storage.systemDatabaseName instead, which defaults to _system:
| Database | Default name |
|---|---|
| Event store state | _system+es |
| Event sequences of the Default namespace | _system+es+Default |
| Read models of the Default namespace | _system |
storage.databaseNamePrefix still comes first, so a staging_ prefix gives staging__system+es. MongoDB does not allow $ in a database name, so $system is not an option. All nodes in a cluster must use the same name, and no other event store can be named the same as the System event store’s databases.
{ "storage": { "type": "MongoDB", "connectionDetails": "mongodb://localhost:27017", "systemDatabaseName": "_system" }}For environment-variable configuration, use Cratis__Chronicle__Storage__SystemDatabaseName.
PostgreSQL
Section titled “PostgreSQL”{ "storage": { "type": "PostgreSql", "connectionDetails": "Host=localhost;Port=5432;Database=chronicle;Username=chronicle;Password=secret" }}Connection pooling
Section titled “Connection pooling”Chronicle keeps a PostgreSQL connection pool per database it uses: the cluster database, each event store,
each namespace, and the read-model databases. With connection resolution configured, the runtime and schema
identities of a database each get their own pool. Idle connections across these pools can reach the
server’s max_connections limit even when no pool is full. Chronicle bounds each pool and prunes idle
connections sooner than Npgsql’s defaults.
{ "storage": { "postgreSqlPooling": { "maxPoolSize": 20, "connectionIdleLifetimeSeconds": 15, "connectionPruningIntervalSeconds": 5 } }}| Property | Default | Description |
|---|---|---|
| maxPoolSize | 20 | Maximum connections in each database’s pool |
| connectionIdleLifetimeSeconds | 15 | Seconds a connection can remain idle before closing when the pool exceeds its minimum size |
| connectionPruningIntervalSeconds | 5 | Seconds between samples for pruning idle connections; must be greater than zero and no greater than the idle lifetime |
These settings shorten how long idle connections are held; they do not cap the total across pools, kernel
replicas, or other clients of the same server. The peak connection count is roughly the number of databases
multiplied by maxPoolSize, per kernel. Keep
max_connections above the expected concurrent demand. When serving many event stores or namespaces,
lower maxPoolSize or the idle lifetime to reduce the connections held across their pools. A lower
maximum means operations can wait for a connection during bursts, and fail with The connection pool has been exhausted only when the wait exceeds the connection Timeout (15 seconds by default). Each
operation holds a connection only for its own commands, so 20 serves a typical namespace. Increase
maxPoolSize for a namespace with many active observers (more than about 30), heavy replays, or a slow
database server, and raise max_connections to match.
Values in connectionDetails, or a resolved connection string, take precedence over these settings.
The keys Maximum Pool Size, Connection Idle Lifetime, Connection Pruning Interval, and
Minimum Pool Size remain available there. The effective maximum is at least the minimum pool size;
the pruning interval is limited to the idle lifetime and stays at least one second. These settings
apply only to PostgreSQL; SQL Server and SQLite connection strings are unchanged.
Microsoft SQL Server
Section titled “Microsoft SQL Server”{ "storage": { "type": "MsSql", "connectionDetails": "Server=localhost;Database=chronicle;User Id=chronicle;Password=secret;TrustServerCertificate=True" }}Passwordless Azure authentication
Section titled “Passwordless Azure authentication”On Azure SQL, use a Microsoft Entra ID mode in the connection string instead of a password, for example Authentication=Active Directory Managed Identity;User Id=<client-id>. On Azure Database for PostgreSQL, enable storage.postgreSqlEntra.enabled to acquire and refresh tokens natively with DefaultAzureCredential. Set storage.postgreSqlEntra.managedIdentityClientId for a user-assigned managed identity, and keep the PostgreSQL principal in the connection string’s Username. Omit a password. Native authentication is disabled by default; a connection resolver can still return an Entra access token as the identity when it is disabled. The supported modes, and what not to combine with a resolved token, are in Microsoft Entra ID authentication. For an end-to-end setup, see Run Chronicle on Azure.
SQL database names
Section titled “SQL database names”PostgreSQL and SQL Server isolate event stores, namespaces and projected read models in separate databases. The configured cluster database supplies the prefix:
| Identity | Logical database name |
|---|---|
| Event store | <cluster>+es+<store> |
Namespace, including Default |
<cluster>+es+<store>+<namespace> |
| Default-namespace read models | <cluster>+<store> |
| Named-namespace read models | <cluster>+<store>+<namespace> |
Names within the provider’s limit stay unchanged: 63 UTF-8 bytes for PostgreSQL, 128 UTF-16 code units for SQL Server. Longer names use a readable prefix, ~, and the first 16 lowercase hexadecimal characters of the SHA-256 of the full logical name in UTF-8. The prefix ends at a Unicode character boundary. The configured cluster name is never shortened; startup rejects it if it exceeds the limit.
Permanent bindings
Section titled “Permanent bindings”The cluster’s DatabaseNames table records each identity’s physical database name. Short names are bound too. Its logical key is (Kind, EventStore, Namespace); Namespace stores Default explicitly, including for event store identities. PhysicalName is unique under PostgreSQL’s ordinal equality or SQL Server’s server collation. The configured cluster database has a reserved row with Kind = 0, an empty EventStore, and Namespace = 'Default'.
| Kind | Identity |
|---|---|
0 |
Cluster |
1 |
Event store |
2 |
Namespace |
3 |
Read models |
Bindings survive restarts and development wipes. Adding a namespace cannot move an existing database. A namespace is bound before it is made available; another kernel can reload that binding when resolving jobs storage. An unbound jobs identity fails instead of guessing a database name.
For an existing PostgreSQL deployment, Chronicle preserves a legacy truncated database only where ownership is clear. An event store takes precedence over its own namespaces and read models; default-namespace read models take precedence over that store’s named-namespace read models. Unrelated stores or namespaces have no precedence. A losing identity gets a separate hashed database, with a warning, only if the shared database contains no schema or migration history that could belong to it.
Resolve shared legacy ownership
Section titled “Resolve shared legacy ownership”DatabaseOwnershipUnresolved names the identity, shared database and competing claimants. Do not delete migration history or repeatedly restart the kernel: that can strand event history in the old database while new writes go elsewhere.
- Stop every kernel using this cluster database and take a recoverable backup of the cluster and shared database.
- Identify which tables and rows belong to the reported identity. Event store metadata, namespace events/constraints/observer state/jobs, and projected read models have different owners. If two identities’ rows are mixed in the same table, separate them from verified business identity information before proceeding; do not copy another identity’s data.
- Create a separate target database with a valid physical name, on the same server and with the required permissions. Use the computed hashed name or another unused name within the provider limit.
- Copy the identity’s tables, data, indexes, constraints and any required dependencies. Copy only its
__EFMigrationsHistoryrows: a namespace owns the rows starting withNS-and the jobs rows starting withCratis-Orleans-Jobs-; every other row belongs to the event store. Read model databases normally have no EF migration history. Preserve the original database until recovery is verified. - Insert the identity’s binding into the cluster’s
DatabaseNamestable. Use its exact store and namespace, the kind from the table above and the target physical name. Do not update an existing binding. Both unique constraints must hold; a duplicate is a conflict to investigate, not a row to overwrite. - Restart the kernels. Chronicle honors the inserted binding. Confirm migrations complete and the identity’s events, jobs and read models are reachable before retiring any original data.
For example, bind a namespace named TenantA in store Orders to a database you have already created and populated. On PostgreSQL, run this in the cluster database:
INSERT INTO "DatabaseNames" ("Kind", "EventStore", "Namespace", "PhysicalName")VALUES (2, 'Orders', 'TenantA', 'orders_tenant_a_recovered');On SQL Server, the equivalent insert is:
INSERT INTO [DatabaseNames] ([Kind], [EventStore], [Namespace], [PhysicalName])VALUES (2, N'Orders', N'TenantA', N'orders_tenant_a_recovered');DatabaseMigrationIncomplete is a different failure: an object already exists but EF migration history still has pending migrations. The error names the database and first pending migration. Repair the schema/history mismatch from a backup and verified schema evidence; Chronicle does not treat duplicate objects as proof that migration completed.
Platform-managed databases
Section titled “Platform-managed databases”When a platform decides where each event store and namespace lives, configure storage connection resolution to resolve the server, database, schema and identity per namespace and purpose. createIfMissing: false stops Chronicle from creating databases, and schema keeps its tables in the schema you grant.
SQLite
Section titled “SQLite”{ "storage": { "type": "Sqlite", "connectionDetails": "Data Source=/data/chronicle.db" }}In-memory
Section titled “In-memory”The in-memory backend keeps every event sequence, observer, read-model sink, and system record in process memory. There is no connection string, and connectionDetails is ignored.
{ "storage": { "type": "InMemory" }}When you host Chronicle programmatically, select the in-memory backend with the WithInMemory() builder extension instead of configuration:
siloBuilder.AddChronicleToSilo(chronicle => chronicle.WithInMemory());Kotlin does not support this workflow yet.Java does not support this workflow yet.Elixir does not support this workflow yet.TypeScript does not support this workflow yet.| Property | Type | Required | Description |
|---|---|---|---|
| type | string | Yes | Storage type: MongoDB, PostgreSql, MsSql, Sqlite, or InMemory |
| connectionDetails | string | Conditional | Connection string for the chosen storage backend. Required for all backends except InMemory, which ignores it |
| connectionDetailsFile | string | No | Path of a file holding the connection string, such as a mounted Kubernetes Secret. Read once at startup and trimmed of a trailing newline. Set either this or connectionDetails, not both |
| databaseNamePrefix | string | No | Prefix prepended to every MongoDB database name. Defaults to empty; ignored by other storage backends |
| systemDatabaseName | string | No | Name the System event store’s MongoDB databases are named by. Defaults to _system; ignored by other storage backends |
| schema | string | No | SQL schema Chronicle keeps its tables in. Defaults to empty, the database user’s default schema; ignored by MongoDB and SQLite |
| createIfMissing | boolean | No | Whether Chronicle creates missing databases and schemas. Defaults to true |
| connectionResolution | object | No | Resolves the server, database, schema and identity per event store, namespace and purpose. See storage connection resolution |
Read the connection from a file
Section titled “Read the connection from a file”In Kubernetes a connection string is a Secret, and the safe way to hand a Secret to a pod is a mounted file. An environment variable exposes the value to anything that can read the pod’s environment. Set connectionDetailsFile to the path of the file instead of connectionDetails:
{ "storage": { "type": "PostgreSql", "connectionDetailsFile": "/var/run/secrets/chronicle/storage" }}Or through the environment:
Cratis__Chronicle__Storage__ConnectionDetailsFile=/var/run/secrets/chronicle/storageThe Kernel reads the file once, at startup, and trims a trailing newline. It stops startup with exit code 4 and a message naming the setting when:
connectionDetailsandconnectionDetailsFileare both set;- the file does not exist, is a directory, cannot be read, or is empty.
The message names the setting and the path of the file, never what the file holds.
Named sinks read their connections from files the same way; see Named sinks.
Single-writer lease storage
Section titled “Single-writer lease storage”In Localhost clustering mode, persistent storage is protected by one lease per kernel system/cluster
database. SQL providers create the additive SingleWriterLeases table; MongoDB uses the
single-writer-leases collection. Both store the fixed kernel key, process owner, cluster and service
identities, host, version, acquisition time, last renewal and expiry. Cluster and service identities are
diagnostic metadata, not part of the lease key. Keep all nodes that share kernel data on the same
system/cluster database; independently resolved system databases cannot protect each other’s data.
Released or expired records are retained for diagnostics. MongoDB does not use a TTL index. The lease uses the normal cluster database resolution and migration path, including SQL schemas and identities. See Single-writer lease for settings, shutdown and SQLite clock caveats.