Database tables
This page describes the tables used by the KMS server to persist its data, and the links between them. It applies to the SQL backends: SQLite, PostgreSQL, MySQL, MariaDB, and Percona XtraDB Cluster.
The Redis-with-Findex backend does not use relational tables; see Redis with Findex.
Overview
The KMS object-store schema has nine tables shared by all SQL backends, plus object_state_events and object_state_event_tombstones on PostgreSQL, and kms_migration_lock, kms_cron_locks and kms_cron_leases on MySQL, MariaDB, and Percona XtraDB Cluster. The optional PostgreSQL audit backend adds kms_audit_events and kms_audit_control in its own separate database.
| Table | Purpose |
|---|---|
parameters | Internal key/value store (migration state, database version, one-time markers) |
objects | KMIP objects (keys, certificates, secrets, and so on) |
read_access | Per-user read permissions granted on objects |
tags | Tags attached to objects, used by Locate |
crypto_officer_activations | Records of the Crypto Officer activation ceremony |
crls | Most recently signed CRL per issuer CA (RFC 5280 §5), for CDP serving after restart |
ui_session_revocations | Web UI sessions revoked by logout, shared by every KMS instance on the database |
gcm_invocations | Number of AES-GCM invocations with a random IV made with each key (NIST SP 800-38D §8.3) |
cluster_nodes | Recent node heartbeats, KMS version, and elected leader |
object_state_events, object_state_event_tombstones | Insert-only object lifecycle log from which objects.state is derived (PostgreSQL only) |
kms_migration_lock | Startup migration coordination row (MySQL, MariaDB, and Percona XtraDB Cluster only) |
kms_cron_locks | Row locks of the previous release's scheduled jobs when GET_LOCK is refused; no longer used (MySQL, MariaDB, and Percona XtraDB Cluster only) |
kms_cron_leases | Scheduled-job TTL leases (MySQL, MariaDB, and Percona XtraDB Cluster only, when GET_LOCK is refused) |
Every PostgreSQL deployment, single- or multi-region, keeps the lifecycle state of objects in the two insert-only tables object_state_events and object_state_event_tombstones, created at startup, from which ENABLE ALWAYS triggers derive objects.state. In a multi-region active-active deployment they make the state converge across regions (see Multi-region active-active PostgreSQL).
The links between tables are logical relationships (enforced by the application, not by SQL foreign-key constraints).
On a multi-region deployment, which of these tables are replicated, and how Spock (PostgreSQL) or Galera (MySQL) selects them, is explained in Which tables are replicated.
objects
The central table. One row per KMIP object.
| Column | Type | Description |
|---|---|---|
id | VARCHAR(128) | Primary key. The object's unique identifier (UID). |
object | VARCHAR (PG/SQLite) / LONGTEXT (MySQL) | The serialized KMIP object (JSON). |
attributes | jsonb (PG) / json (MySQL) | The KMIP attributes attached to the object. |
state | VARCHAR(32) | The KMIP lifecycle state of the object (for example Active, Destroyed). |
owner | VARCHAR(255) | The user identifier of the object's owner. |
wrapping_key_id | VARCHAR(128) | The UID of the key that wraps this object. Self-reference to objects.id. |
version | BIGINT NOT NULL DEFAULT 0 (PG/MySQL) / INTEGER NOT NULL DEFAULT 0 (SQLite) | Optimistic-lock counter, incremented on every write; key rotation commits only if the version it read is still current. |
The following secondary indexes are created on objects:
| Index | Columns | Backends |
|---|---|---|
idx_objects_owner | owner | all |
idx_objects_state | state | all |
idx_objects_wrapping_key_id | wrapping_key_id | all |
idx_objects_rotate_name | RotateName attribute, owner (partial: RotateName present) | PostgreSQL, SQLite |
idx_objects_rotate_auto | state (partial: RotateAutomatic = true) | PostgreSQL, SQLite |
idx_objects_type_state | ObjectType attribute, state | PostgreSQL, SQLite |
Indexes are created at server startup. On an existing large database, the first start after an upgrade takes proportionally longer, and PostgreSQL blocks writes to objects while each new index builds.
Downgrade (Usage Limits). The current release consumes the KMIP Usage Limits budget of an object by decrementing UsageLimitsCount and never changes UsageLimitsTotal, the configured budget; both are stored in the attributes column and in the key block attributes. The remaining budget is the smaller of the Count and the Total, or the Total when the Count is absent. Releases before it ignore the Count and decrement and enforce the Total only. After an upgrade, objects written by such a release therefore keep their remaining budget, including those carrying a stale Count above their decremented Total. The downgrade verdict is DEGRADED:
- An earlier release grants every usage-limited object its full Total again, including objects the current release has exhausted, unless the procedure below runs first.
- Mixed-version operation (an earlier release and the current release serving the same database, for example during a rolling restart) is not supported for usage-limited objects: the two releases cannot share one representation of the budget, and the earlier release ignores the consumption recorded by the current release.
To downgrade without restoring spent budgets:
- Quiesce all writers: stop client traffic and every server instance except one current-release instance, reachable only by the administrator.
- For each object that carries a
UsageLimitsattribute, read it withckms attributes get --id <UID> --attribute UsageLimitsand compute the remaining budget: the smaller ofUsageLimitsCountandUsageLimitsTotal, orUsageLimitsTotalwhen the Count is absent. - As the object owner, or a user granted
ModifyAttributeon the object, send a KMIPModifyAttributerequest whoseNewAttributeisUsageLimitswith the sameUsageLimitsUnitandUsageLimitsTotalset to the remaining budget, as JSON TTLV to the/kmip/2_1endpoint (see The JSON TTLV KMIP API). The server sets the Count to the new Total.ckms attributes setandckms attributes modifycannot setUsage Limits. - Verify with
ckms attributes get --id <UID> --attribute UsageLimitsthatUsageLimitsTotalandUsageLimitsCountboth equal the remaining budget, back up the database, stop the last current-release instance, then start the earlier release.
After upgrading again, the Total the earlier release decremented caps the remaining budget, so its consumption is kept.
Downgrade (MySQL). SAFE. No storage change: an older node writes the state and the payload without the lifecycle join and the Destroyed guard, as before.
Row binding. When the server key_encryption_key (KEK) is configured, the wrapped plaintext of every
object it protects carries the vendor attribute x-cosmian-stored-uid (vendor cosmian), the UID of the
row, in the key value attributes, and the wrapping uses the TTLV encoding. The server refuses to
unwrap an object whose binding is missing or names another row, so a ciphertext copied from one row to
another (same or different owner) is no longer served. Objects wrapped by an explicit user wrapping key
are not concerned. The binding covers the UID only: a database writer who can change owner can also add
read_access rows, so binding the owner would protect nothing.
The binding is only as strong as the integrity of the KEK wrapping. It holds with an AES KEK (AES key wrap,
AES key wrap with padding, AES-GCM, including an HSM AES KEK). With an RSA KEK, anyone who holds the
public key can build a ciphertext, so the binding does not stop a database writer who forges one.
An RSA KEK wraps with CKM_RSA_AES_KEY_WRAP (RSA-OAEP of an ephemeral AES-256 key, then AES key wrap with
padding), so neither the UID length nor the key type is limited. An HSM RSA KEK builds it from the HSM's RSA-OAEP,
and uses plain RSA-OAEP while the object fits one block (190 bytes with a 2048-bit key and SHA-256).
At every start with a KEK, the server wraps again, bound to their row, the objects wrapped by the KEK
that carry no binding (query select-ids-wrapped-by). It trusts the rows it finds at that moment: it
cannot tell a ciphertext moved before the first start of this version from a genuine row. An object
bound to another row is left unchanged and fails on read. Without a KEK, objects are stored in clear and
are not bound.
Downgrade (row binding). BREAKING for mixed-version operation, DEGRADED for a downgrade (verdict of
/kms-db-compat; the change needs the approval given in
issue #1519).
- No table, column or query used by the previous release changes. The previous release unwraps a bound object
with the TTLV encoding recorded in its key wrapping data, and returns the key material unchanged, but the
unwrapped key value keeps the attribute
x-cosmian-stored-uid. The previous release does not reattach the stored attributes to a key value that has attributes, so a bound object that is itself used by the previous release to wrap or unwrap other keys is refused with a missing usage mask. - Rows the previous release writes carry no binding. This version refuses them until it is restarted, which binds them again: do not run both versions at once on one database with a KEK (rolling upgrades are not supported).
- To downgrade, stop every instance of this version, start the previous release, and bind again by starting this version when upgrading back.
- A software RSA KEK wraps with
CKM_RSA_AES_KEY_WRAP, which the previous release reads. An HSM RSA KEK keeps RSA-OAEP for an object that fits one block; a larger object (long UID, RSA private key) is wrapped withCKM_RSA_AES_KEY_WRAP, which the previous release cannot read from an HSM KEK: the previous release could not store these objects, so a downgrade needs the pre-upgrade backup when such rows exist.
read_access
Stores the operations that a given user is allowed to perform on a given object.
| Column | Type | Description |
|---|---|---|
id | VARCHAR(128) | The object UID. References objects.id. |
userid | VARCHAR(255) | The user identifier granted access. |
permissions | json | The operations granted to the user, serialized as JSON. |
The pair (id, userid) is unique.
In PostgreSQL (converted at startup) and MySQL (since 5.14.0), it is the composite PRIMARY KEY (id, userid) (providing valid REPLICA IDENTITY for logical replication); in SQLite it is declared UNIQUE (id, userid).
A secondary index idx_read_access_userid is created on userid.
Downgrade. SAFE. The PostgreSQL primary key covers the columns of the previous unique constraint, and an older KMS always writes both columns. Its ON CONFLICT (id, userid) is served by the key.
tags
Stores the tags attached to objects. Tags are used to locate objects by tag.
| Column | Type | Description |
|---|---|---|
id | VARCHAR(128) | The object UID. References objects.id. |
tag | VARCHAR(255) | A single tag. |
The pair (id, tag) is unique.
In PostgreSQL (converted at startup) and MySQL (since 5.14.0), it is the composite PRIMARY KEY (id, tag) (providing valid REPLICA IDENTITY for logical replication); in SQLite it is declared UNIQUE (id, tag).
A secondary index idx_tags_tag_id on (tag, id) supports Locate-by-tags lookups.
Downgrade. SAFE. The PostgreSQL primary key covers the columns of the previous unique constraint, and an older KMS always writes both columns.
parameters
A generic key/value store used internally by the KMS for database metadata.
| Column | Type | Description |
|---|---|---|
name | VARCHAR(128) | Primary key. The parameter name. |
value | VARCHAR(256) | The parameter value. |
Known parameters:
name | Meaning |
|---|---|
db_state | Database migration state ("ready" or "upgrading"). |
db_version | KMS version the database was last migrated to. |
attributes_jsonb_converted | PostgreSQL-only marker recording that objects.attributes was converted to jsonb. |
min_compatible_version | Oldest KMS release able to serve this database; startup is refused only when it is newer than the binary (db_version is the fallback when it is absent). Never lowered. |
wrapping_key_id_backfilled | One-time marker recording that the objects.wrapping_key_id backfill completed. |
kek_row_bound | UID of the key_encryption_key under which every stored object is bound to its database row. Written only by a startup pass that hit no error (rows bound to another row are logged, not retried), so the scan is skipped while the UID is unchanged and rerun after a KEK change. Delete it to force a new scan (for example after an older server ran on the database). |
certificate_serial_tag_backfilled | One-time marker recording that the _serial=<HEX> tag backfill for existing certificates completed. |
stored_state_synced | One-time marker recording that the StoredStateSync startup step (lifecycle State written into the stored attributes and key-block attributes) completed. |
kv_metadata_uid_key | Hex-encoded 32-byte key initialized by the leader region at startup; followers only read it after replication. It derives internal identifiers for the KV secret store and SSH CA/role records. On Redis-Findex it is stored AES-256-GCM encrypted under kms::parameter::kv_metadata_uid_key. |
Downgrade (min_compatible_version). SAFE for a rollback inside the compatibility window: the older binary starts, leaves db_version and the schema untouched, and ignores the parameter. A KMS that predates the parameter ignores it and keeps refusing on db_version. Replication. The parameter lives in parameters, in the shared database, and is stamped under the migration lock; name is the primary key, so concurrent starts of different versions in a cluster resolve by last write, and the stamping never lowers an existing value. Operators of an upgraded Spock deployment need to run nothing: the table already exists and is replicated.
Downgrade (stored_state_synced). DEGRADED, cosmetic. An older KMS reads the lifecycle state from the objects.state column (the stored attribute State only matters while the column is PreActive) and ignores the marker, so the rewritten JSON is harmless. The database keeps db_version at this version, so the step does not run again on a later upgrade, and state JSON that the older KMS let lag stays as it is. The swapped-role gate run (mise run test:db:upgrade --backend sqlite --old-kms <this build> --new-kms <5.29.0 build>) fails at the first GetAttributes of mig_kek with one or more objects already exist; it fails identically when the old server is the unmodified develop build, so the failure is not caused by this step (its cause was not investigated), and the run cannot confirm the state-JSON rewrite on its own. The claim above comes from reading the 5.29.0 read path, not from a passing downgrade run.
Replication (stored_state_synced). The step adds no table, column or key, and the marker lives in parameters, in the shared database. On SQLite, PostgreSQL and MySQL it reads each row, then rewrites objects.object and objects.attributes with an UPDATE guarded by the object, attributes and state values it read, so a row another client or instance of the same database rewrote in between is left unchanged and keeps the stored State JSON that writer produced. The guard cannot see a write that has not reached the local node yet: under Spock (asynchronous replication) a remote region's write can still be overwritten by the sync, so stop every other region's writers before the first start of this version; Galera certifies writes synchronously, so the guard covers it. Redis-with-Findex has no guard: its sync rewrites the object, attributes and tags it scanned, so stop all other instances before the first start of this version. The step runs under the startup migration lock, which serializes migrating instances but not instances already serving requests. On PostgreSQL the step runs in one transaction, which can be long on a large objects table. No Spock command is required after the upgrade.
kms_migration_lock
Used on MySQL, MariaDB, and Percona XtraDB Cluster to serialize startup migrations across concurrently starting KMS instances.
| Column | Type | Description |
|---|---|---|
id | TINYINT | Primary key (contains a single coordination row id = 1). |
kms_cron_locks
Used by KMS versions before 6.0 on MySQL, MariaDB, and Percona XtraDB Cluster when the server refuses GET_LOCK (Galera): a scheduled job held its row FOR UPDATE NOWAIT in an open transaction, which excluded only the KMS nodes connected to the same database node. The current KMS no longer reads or writes it (see kms_cron_leases) but still creates it at startup (CREATE TABLE IF NOT EXISTS).
| Column | Type | Description |
|---|---|---|
name | VARCHAR(128) | Primary key: the job lock name. |
Downgrade. An older KMS ignores this table; the only effect is that its scheduled jobs run on every node, as before this table existed.
kms_cron_leases
Used on MySQL, MariaDB, and Percona XtraDB Cluster when the server refuses GET_LOCK (Galera). A scheduled job takes a committed, replicated lease on its row, so the job runs on one KMS node of the whole cluster, whichever database node it is connected to. The running job renews the lease every 100 seconds; a holder that dies loses it after 300 seconds. Times come from the clock (CURRENT_TIMESTAMP(6)) of the database node running each statement: keep the Galera nodes NTP-synchronised. Created at startup (CREATE TABLE IF NOT EXISTS).
| Column | Type | Description |
|---|---|---|
name | VARCHAR(128) | Primary key: the job lock name. |
holder | VARCHAR(64) | Random identifier of the lease holder (a new one per acquisition). |
expires_at | DATETIME(6) | Instant after which another node may take the lease over. |
Downgrade. SAFE. An older KMS ignores this table; its scheduled jobs then use kms_cron_locks again (one node per database node, as before). During a rolling upgrade, nodes of different versions do not exclude each other: the coordination is degraded until every node runs 6.0.
crypto_officer_activations
Records the Crypto Officer activation ceremony. One row is added each time the Crypto Officer role is activated via a split-key ceremony.
| Column | Type | Description |
|---|---|---|
activated_at | TIMESTAMP | When the activation was created (defaults to CURRENT_TIMESTAMP). |
sealed_record | TEXT | The sealed record produced by the activation ceremony (AES-256-GCM encrypted). |
revoked_at | TIMESTAMP | When the activation was revoked, or NULL while still active. |
revoked_by | VARCHAR(255) | The user who revoked the activation. |
In MySQL, an additional id INTEGER PRIMARY KEY AUTO_INCREMENT column is added.
In PostgreSQL, an id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY column is added to provide valid REPLICA IDENTITY for logical replication.
In SQLite there is no explicit id column; the active activation is the latest row where revoked_at IS NULL.
Revocation erases sealed_record (empty string); a record is valid only for the user it was sealed for. At startup, records revoked by an older KMS are erased too.
Downgrade. SAFE. The PostgreSQL identity column id is filled automatically; an older KMS inserts with an explicit column list and never reads revoked rows (revoked_at IS NULL filter), so their emptied sealed_record is ignored. Rows an older KMS revokes keep their sealed record until the next start of this version.
Accepted residual risk. The sealed record is not bound to the time of the activation: a database writer who
copied an active sealed_record can insert it again for the same user after the activation was revoked, and
reactivate the role. Restrict write access to this table and audit its changes. See
issue #1519.
object_state_events and object_state_event_tombstones
PostgreSQL only. Insert-only lifecycle log from which objects.state is derived by ENABLE ALWAYS triggers (see State conflict resolution). Both tables have a UUID primary key and are never updated.
| Column | Type | Description |
|---|---|---|
event_id | UUID | Primary key of the event. |
object_id | VARCHAR(128) | The objects.id the event applies to. |
state | VARCHAR(32) | The lifecycle state recorded. |
object | VARCHAR | For Destroyed events, the zeroized object JSON snapshot; otherwise NULL. |
wrapping_key_id | VARCHAR(128) | For Destroyed events, the wrapping key id snapshot; otherwise NULL. |
recorded_at | TIMESTAMPTZ | When the event was recorded. |
object_state_event_tombstones holds only event_id UUID PRIMARY KEY: an event listed there no longer counts (used by backward transitions such as batch UNDO).
Applying a lifecycle event or a tombstone also advances objects.version. Conditional writes using a snapshot from before that transition fail with a conflict, including when the event arrived through replication.
Downgrade. DEGRADED. Release 5.29.0 predates the migration runner's newer-version check: it starts on this database. A binary with that check refuses startup only when the recorded database version exceeds its own version.
With the lifecycle triggers installed, older nodes' direct state writes are replaced by the event-derived state. Activate, Revoke and Destroy therefore cannot change the state of objects with events. Destroy can still zeroize their payload.
Stop all older nodes before starting this release. Do not use mixed-version rolling restarts. Repeat lifecycle operations served by older nodes after the cutover; startup cannot reconstruct transitions that the trigger suppressed.
Older releases' deletes and clear_database leave events and tombstones behind. Startup purges these orphans and adds baseline events for event-less objects.
It also records stored states that add information to the event join, preserving later phases and compromise status.
Deliberate PostgreSQL downgrade and return
This procedure addresses the lifecycle triggers only; it does not establish compatibility of unrelated release changes.
-
Stop every KMS node in every region, let replication catch up, and back up each database before modifying it.
-
On each database, remove the lifecycle triggers below. Do not assume that DDL is replicated. Keep the event tables and their contents.
BEGIN; DROP TRIGGER IF EXISTS trg_objects_state_derive ON objects; DROP TRIGGER IF EXISTS trg_object_state_events_apply ON object_state_events; DROP TRIGGER IF EXISTS trg_object_state_event_tombstones_apply ON object_state_event_tombstones; COMMIT; -
Start the older release. This procedure does not bypass a newer-version refusal in a binary that implements that check.
-
Before returning to this release, stop every older node again and let replication catch up. Startup reinstalls the triggers and appends missing state information from
objects, including a Destroyed payload snapshot.
Limits. Reconciliation preserves the join, not an arbitrary replacement: a state lowered by the older release (such as batch UNDO) cannot override surviving events. Do not delete and recreate an object with the same UID during the downgrade.
If a UID is reused, surviving events can override the replacement object's state or payload. The older release's clear_database does not remove this risk. Use a tested backup/restore plan for these cases.
The startup scan evaluates the surviving event join for every object. Its cost grows with the object and event counts; events are not compacted.
crls
Stores the most recently generated CRL for each issuer CA, persisted so that the
public CDP endpoint (GET /public/certificates/{issuer_id}/crl) can serve the
last signed CRL immediately after a server restart without requiring a manual
generate-crl call.
One row per CA certificate. The row is replaced atomically on every CRL regeneration
(upsert on issuer_id).
| Column | Type | Description |
|---|---|---|
issuer_id | VARCHAR(128) | Primary key. The UID of the issuer CA certificate in the objects table. |
crl_der | BYTEA (PG) / BLOB (SQLite) / LONGBLOB (MySQL) | DER-encoded signed CRL bytes. |
crl_number | BIGINT | Monotonically increasing CRL sequence number (RFC 5280 §5.2.3). |
generated_at | VARCHAR(32) | ISO-8601 UTC timestamp of when this CRL was signed. |
next_update | VARCHAR(32) | ISO-8601 UTC timestamp of CRL expiry (= generated_at + validity days). |
The Redis-with-Findex backend stores each CRL as a JSON value under the key
crl:<issuer_id>.
ui_session_revocations
/ui/logout records the id of the Web UI session it ends here, and every KMS instance sharing the
database refuses a cookie carrying a revoked id, so a logout on one node of a load-balanced
deployment is honored by all of them. Each authenticated request that carries a session cookie
reads one row by primary key; a failed read refuses the session.
| Column | Type | Description |
|---|---|---|
sid | VARCHAR(64) | Primary key. The random session id (32 hex characters) sealed in the cookie. |
expires_at | BIGINT | Absolute expiry of the session (Unix seconds). A revocation older than this is useless and is deleted at the next logout. |
The Redis-with-Findex backend stores a key ui_session_revoked:<sid> with a time-to-live equal to the
remaining lifetime of the session, so Redis expires it by itself.
Replication. The table is read from the database on every request, so it needs no replication in a
cluster of KMS instances sharing one database. It is an ordinary public table with a primary key and
is replicated like the other ones:
- Galera: replicated synchronously, like every InnoDB table.
- PostgreSQL with Spock (multi-region): it is part of the replication set created by
spock.repset_add_all_tables('default', ARRAY['public']). On a deployment that was set up before this table existed, add it on every node after upgrading, otherwise a logout is not seen by the other regions:SELECT spock.repset_add_table('default', 'ui_session_revocations');. Revoking the same session in two regions at once inserts the same row twice, which converges. Replication is asynchronous: a region that has not received the row yet still accepts the cookie, for the length of the replication lag. - Redis-with-Findex: not a multi-region backend; in a cluster the instances share the same Redis.
Downgrade. SAFE. An older KMS ignores this table. The Web UI cookies of the two releases are not interchangeable (the session key derivation changed), so a revoked session cannot be replayed on an older node.
gcm_invocations
NIST SP 800-38D §8.3 allows at most 2^32 AES-GCM invocations with a random IV under one key.
The server reserves each invocation in this table before encrypting, so a crash wastes an
invocation and never lets one be used twice. It counts one per single-part Encrypt, one per
multi-part Encrypt stream, one per item of a bulk Encrypt, one per AES-GCM MAC (GMAC) and
one per software AES-GCM key wrap. Decryption is not counted.
| Column | Type | Description |
|---|---|---|
object_id | VARCHAR(128) | Primary key. The UID of the AES key in the objects table. |
count | BIGINT | Invocations made so far, at most 4294967296 (2^32). |
The row is independent of the object: counting does not change the object version, so it never
conflicts with a ReKey or any other write to the key, and it is not visible through KMIP
attributes. Once the cap is reached, Encrypt, MAC and wrapping with that key fail with
Permission_Denied: rekey. Destroying or deleting the key deletes the row; a new key starts at 0.
The count is per UID, not per key material: exporting a key and importing it again under another
UID restarts the count. Keeping a key fresh is the operator's responsibility (SP 800-38D §8.1).
Keys held in an HSM are not counted here: the HSM module enforces the cap under its Security
Policy. The Redis-with-Findex backend (non-FIPS builds only) keeps the count in
gcm_invocations::<uid> keys instead of a table.
Multi-region. Every region increments the count of a key, so the table is replicated with Spock delta-apply on
count (each region's increment is added, not overwritten): see
Scheduled jobs and cluster coordination.
Downgrade. An older KMS ignores this table (and the Redis keys). It does not count its own
AES-GCM invocations, so after upgrading again the count under-reports those invocations: rekey
AES-GCM keys that were used heavily while downgraded. An older KMS also deletes keys without
deleting their counters; the upgraded server removes counters whose object no longer exists at
every startup. To remove the counters manually, run DROP TABLE gcm_invocations; (SQL) or
redis-cli --scan --pattern 'gcm_invocations::*' | xargs -r redis-cli DEL (Redis).
cluster_nodes
Stores one heartbeat per running KMS process. Each node refreshes its row every five seconds; rows older than fifteen seconds are pruned. One node is marked as leader for display; no work depends on it. Node IDs are regenerated on process restart, and stale rows are removed by the next heartbeat.
| Column | Type | Description |
|---|---|---|
node_id | VARCHAR(64) (PG/MySQL) / TEXT (SQLite) | Process-specific UUID and primary key. |
version | VARCHAR(64) (PG/MySQL) / TEXT (SQLite) | KMS package version reported by the process. |
last_heartbeat | BIGINT (PG/MySQL) / INTEGER (SQLite) | Last heartbeat as Unix seconds. |
is_leader | BOOLEAN (PG/MySQL) / INTEGER (SQLite, 0 or 1) | Whether this node is the displayed cluster leader. |
In a multi-region active-active deployment each region keeps its own rows: remove the table from the replication set (see Scheduled jobs and cluster coordination).
Links between tables
objects.idis referenced byread_access.idandtags.id: one object can have many access rows and many tags.objects.wrapping_key_idpoints toobjects.id: a wrapping key is itself an object, and many objects can be wrapped by the same key.crls.issuer_idlogically referencesobjects.id(the CA certificate): one CA has at most one current CRL row.gcm_invocations.object_idlogically referencesobjects.id(an AES key): one key has at most one counter row.objects.ownerandread_access.useridhold user identifiers. Users are authenticated identities and are not stored in a dedicated table.parametersandcrypto_officer_activationsare standalone and do not referenceobjects.cluster_nodesis a standalone, ephemeral registry; it does not referenceobjects.
These relationships are managed by the application layer (crate/server_database/) rather than database foreign-key constraints.
PostgreSQL audit database
Used only by the PostgreSQL audit backend
(--audit-postgres-url), in a database distinct from the object store. Its schema is defined in
audit.sql.
kms_audit_events
Append-only, hash-chained audit events. One row per event.
| Column | Type | Description |
|---|---|---|
instance_id | TEXT | KMS instance owning the chain (1 to 255 characters). |
chain_generation | BIGINT | Chain generation (≥ 0); a new one starts after a seal-and-roll. |
id | BIGINT | Position of the event in its generation (≥ 0). |
timestamp | TIMESTAMPTZ | When the event was recorded (microsecond precision). |
operation | TEXT | KMIP operation or audit:* system event. |
username | TEXT | Authenticated user. |
object_uid | TEXT | UID of the object concerned, or NULL. |
algorithm | TEXT | Algorithm used, or NULL. |
client_ip | TEXT | Client IP address, or NULL. |
result | TEXT | Outcome of the operation. |
duration_ms | BIGINT | Duration of the operation in milliseconds (≥ 0). |
request_id | UUID | Request correlation ID, or NULL. |
details | TEXT | Event-specific JSON details, or NULL. |
prev_hash | BYTEA | SHA-256 row_hash of the previous event (32 bytes; zeros for the first event). |
row_hash | BYTEA | SHA-256 of this row's fields and prev_hash (32 bytes). |
The primary key is (instance_id, chain_generation, id). A secondary index
idx_kms_audit_events_timestamp on timestamp serves auditors' time-range queries; the KMS
does not use it.
These triggers keep the table append-only:
| Trigger | Fires | Effect |
|---|---|---|
kms_audit_no_update | BEFORE UPDATE, per row | Rejects the update (kms_audit_reject_mutation()). |
kms_audit_no_delete | BEFORE DELETE, per row | Rejects the delete (kms_audit_reject_mutation()). |
kms_audit_no_truncate | BEFORE TRUNCATE, per statement | Rejects the truncate (kms_audit_reject_mutation()). |
kms_audit_no_insert_sealed | BEFORE INSERT, per row | When the instance has a kms_audit_control row, rejects an insert into any generation other than its active_generation (kms_audit_reject_sealed_insert()). |
UPDATE, DELETE and TRUNCATE are also revoked from PUBLIC.
kms_audit_control
The generation currently accepting writes, per instance.
| Column | Type | Description |
|---|---|---|
instance_id | TEXT | Primary key. KMS instance (1 to 255 characters). |
active_generation | BIGINT | Generation currently accepting writes (≥ 0). |
updated_at | TIMESTAMPTZ | When active_generation last changed (defaults to now()). |
kms_audit_events.instance_id logically references kms_audit_control.instance_id; as for the
object-store tables, there is no foreign-key constraint.