Skip to content

Persistence

A node keeps its state behind a port, store.Port. The shipped backend is SQLite: the store package works on a *sql.DB it is handed — the host opens the database, picks the driver and owns the handle, or the node opens it for Config.Store.Path — and embeds the DDL its queries are written against and applies it. store.OpenSQLite is the module's opener (the pure-Go driver and its pragmas), which Config.Store.Path and controller.OpenDB use; store.New itself never opens a database. The second backend, store/memstore, keeps the same state in memory. This page describes the port and what a backend of a host's own must guarantee, then lists what SQLite stores where, what survives a restart, and how schema changes reach a host.

The persistence port

store.Port is the sum of one interface per area of the node's state, each named after the Matter concept it holds and carrying exactly the methods the module's consumers call:

Area Holds Consumers
store.Fabrics the fabric table; AddFabric allocates the index; the hooks a rollback owes (OwedFabricEvents, AckOwedFabricEvent) OperationalCredentials, the node's CASE identities, commissioning window and start, the group manager
store.Identity per fabric: NOC, ICAC, operational key, IPK OperationalCredentials, the node's CASE identities
store.ACL the AccessControl list per fabric AccessControl, the bridge's access checks
store.GroupKeys key sets and the GroupKeyMap; ReplaceGroupKeyMappings swaps a fabric's whole map at once GroupKeyManagement, OperationalCredentials (the IPK set), the group manager
store.Groups the group table and the Groupcast groups (groups.Store embeds it) the group manager
store.Resumption CASE resumption records, one per (fabric, peer) for both roles; a record carries the peer's session parameters (zero is absent) the operational session manager, the node's CASE initiator
store.ServerSubscriptions the subscriptions of active CASE sessions the bridge's subscription persistence
store.Settings string settings and counters; SetSettings writes several keys at once and DeleteSettings deletes several, all or none; DeleteSettingsWithPrefix deletes every key under a root ending in . the facade, AccessControl's Extension, the terms acceptance, the group counter, the event-number ceiling
store.OTA the OTA requestor's DefaultOTAProviders and state the OTA requestor
store.ThermostatPresets a Thermostat endpoint's presets the Thermostat server (store.NewThermostatPresetStore)
store.DoorLocks a lock endpoint's users, credentials and schedules the DoorLock server
store.ICD the ICD Management server's registered Check-In clients with their keys, and the ICDCounter ICD Management (node.Config.ICD)
store.Eraser Erase: every row of every area, the next fabric index back at 1; the SQLite store then rewrites the file and empties its -wal, so the erased bytes remain in none of the store's files (flash wear-levelling, file-system snapshots and backups are beyond the module's reach) the factory reset (node.Node.FactoryReset, controller.Controller.Erase)

A consumer names the areas it uses, never the whole port; the node, which wires every consumer, holds a store.Port.

Two implementations.

  • store.New(db), SQLite. Config.Store.Path and Config.Store.DB build it; Config.Store.Credentials takes one you built. The factory reset erases the stores the node used — an override as it is, whether the node still runs or was stopped before. An endpoint-store override (Config.Store.Endpoints) is erased row by row and not scrubbed: when it keeps its records in a database file of the host's own, scrubbing that file is the host's (store.Scrub).
  • memstore.New() (store/memstore), in memory, for tests and for a small daemon that accepts losing its state on restart: a process that exits forgets every fabric, and each controller has to commission the node again. Pair it with the in-memory endpoint store:
cfg.Store = node.Store{Credentials: memstore.New(), Endpoints: epmem.New()} // epmem: endpoint/memstore

fabrictest devices run on these two by default; fabrictest.Options's StoreOnDisk puts them on a SQLite file.

What a backend of the host's own must guarantee.

  • Atomic per method. A multi-row write (ReplaceACL, ReplaceDefaultOTAProviders, SaveDoorLockAuth, RemoveGroupKeySet, RemoveFabric, …) applies whole or not at all, and a refused write changes nothing. The port has no transaction across methods; a change that spans several settings keys is one SetSettings or DeleteSettings call, which writes every key or none (the SQLite store in one transaction), a GroupKeyMap write is one ReplaceGroupKeyMappings, and a SetVIDVerificationStatement one UpdateFabricVendorVerification (the vendor id and the VID data together). DeleteSettingsWithPrefix refuses a prefix that does not end in ., so scenes.ab. never takes scenes.abc.….
  • A closed backend. After the backend is closed every method returns a non-nil error and changes nothing; the node and the controller call no method after their Stop or Close returned.
  • The fabric cascade. RemoveFabric removes everything the fabric owns: its identity, key sets, key map, group table, Groupcast groups, ACL, resumption records, default OTA providers and ICD registrations. Server subscriptions, presets, lock records, owed fabric events, settings and counters stay; the bridge deletes a removed fabric's subscriptions itself. A row naming a fabric the store does not hold is refused. What a cluster server keeps for a fabric under its own settings key — the AccessControl Extension entry, Binding lists, scene tables, the TLS tables, the trusted time source, and a lock user's or credential's creator and last-modified fabric, which the DoorLock server sets to 0 as connectedhomeip does while the users, credentials and schedules stay — the server drops itself when the node removes the fabric (contract.FabricScopedState), and the node drops what is stored for a fabric the table no longer holds before it serves a topology: at start and whenever an endpoint joins.
  • The fabric row carries its commit state. FabricRecord.Pending is FabricCommitted, FabricPendingAdd (an AddNOC that CommissioningComplete has not committed; AddFabric takes it) or FabricPendingUpdate. UpdateFabricCredentials writes an UpdateNOC's NOC, ICAC, private key and node id in one write — the vendor id and VID data stay as the row holds them when it lands — and, on a committed row, first keeps those values and the vendor id and VID data as the prior and marks the row; a second update before the commit keeps the first prior. CommitFabric commits and erases the prior values; RollbackFabric deletes a pending add with everything it owns, or moves a pending update's prior values back and deletes the fabric's resumption records, and returns the state it found. In the same write it records the hook the rollback owes — the fabric's removal or its update — with the fabric's identity as the row held it (store.OwedFabricEvent); OwedFabricEvents lists them by ID and AckOwedFabricEvent removes one. The node runs the owed hooks at its start and acknowledges each after them, so a crash between a rollback and its hooks delivers them at the next start: at least once. While an update is pending, UpdateFabricVendorID, UpdateFabricNodeID and UpdateFabricVIDVerification change the live values only. Each of these is one atomic write, and the state is on disk with the row, so a restart finds it. Readers see a pending row like any other.
  • Monotonic counters. The fabric index comes from a counter that only moves forward, wraps after 254 and skips occupied indexes, so a removed index is not reissued at once (matter.js FabricManager #nextFabricIndex); SQLite keeps it as the metadata counter next_fabric_index. A metadata counter holds at most 2^62.
  • The settings' keys are the callers'. The store keeps any key as it is given (the settings keys below); ota_requestor.state and door_lock.saved:<key> are written by the store's own OTA and DoorLock methods.
  • Lists in their order (fabrics by index, key sets and the key map and group tables by id, ACL in list order, subscriptions least recently saved first), the not-found sentinels (ErrFabricNotFound, ErrIdentityNotFound, ErrGroupKeySetNotFound, ErrResumptionNotFound), copies (a slice a caller passes or receives is the caller's), and safety for concurrent use.

store/storetest proves it: storetest.Run(t, open) runs one table of cases against any store.Port, each on a fresh store from open. store runs it against SQLite and store/memstore against itself; a host runs it against its own backend:

func TestMyBackend(t *testing.T) {
    storetest.Run(t, func(t *testing.T) store.Port { return mybackend.Open(t.TempDir()) })
}

matter.js has the same seam one level down: a StorageService (packages/general/src/storage/StorageService.ts:37) resolves a driver (file, SQLite or MemoryStorageDriver) behind the abstract StorageDriver (StorageDriver.ts:26-42), the server node receives it through its environment (packages/node/src/node/server/ServerEnvironment.ts:158, :171-174), and each fabric's state lives in a fabric-<index> context (packages/protocol/src/fabric/FabricManager.ts:251) cleared when the fabric is deleted (FabricManager.ts:262-271). go-fabric types the port by area instead of by key-value context, so a backend stores records, not opaque values.

Source: store/port.go (Port, Fabrics, Identity, ACL, GroupKeys), store/memstore/memstore.go (package doc), endpoint/memstore/memstore.go (package doc), store/storetest/storetest.go (package doc), store/contract_test.go, groups/manager.go (Store), fabrictest/site.go (StoreOnDisk), node/config.go (Store).

Opening the database

db, err := sql.Open("sqlite", "file:node.db?_pragma=foreign_keys(1)&_pragma=busy_timeout(5000)")
  • foreign_keys(1) is required: the schema refuses a row that names a fabric the store does not hold, and cascades, only with it on. store.Apply and store.Upgrade refuse a handle without it (store.ErrForeignKeysOff), and with them node.New. Removing a fabric does not rest on it: the store deletes every row the fabric owns itself.
  • busy_timeout makes a contended endpoint-number allocation wait instead of failing.
  • Both pragmas go in the DSN. A pragma set with a statement applies to one pooled connection only.

Config.Store.Path has the node open a file with exactly this DSN (modernc.org/sqlite) and close it on Stop; Config.Store.DB takes a handle you opened.

node.New applies the device schemas (store.Apply and sqlitestore.Apply) to the database on every boot. Both scripts are idempotent.

Source: node/store_path.go, store/doc.go (package doc), node/node.go (openStores).

The device database

Tables of store (the matter_* schema)

Table Since Holds
matter_fabrics v1 (v0.1.0), columns added in v8 each fabric: index, fabric id, node id, root certificate and key, vendor, label, compressed fabric id; since v8 its commit state (pending: 0 committed, 1 an uncommitted AddNOC, 2 an uncommitted UpdateNOC), its VID verification statement and VVSC, and while it is 2 the node id, vendor id and VID data the UpdateNOC replaced
matter_node_identities v1, columns added in v8 and v10 per fabric: NOC, ICAC, the private key, the IPK as the commissioner sent it; since v8, while the fabric is a pending update, the NOC, ICAC and private key the UpdateNOC replaced (the prior key stored as the key is); since v10 the row's seal mark (sealed). The keys are in clear unless the store is store.NewSealed's (sealing at rest)
matter_group_keys v1, a column added in v10 group key sets per fabric, up to three epoch keys; since v10 the row's seal mark
matter_group_key_map v1, rebuilt in v3, a column added in v11 GroupKeyMap: group id to key set; since v3 without a foreign key, so an entry may name a key set not yet written; since v11 the entry's place in the order the map was written (position), the order it reads back in
matter_acl_entries v1 the AccessControl list per fabric, in order
matter_resumption v1, columns added in v9, v10, v11 and v12 CASE resumption records with the peer's CATs, at most 16 of the CASE responder's per fabric (the least recently written goes first, by the store's own write counter write_seq, added in v11); the records the CASE client writes have a bound of their own, 1024 per fabric, and each role evicts only its own (the role, initiator, added in v12; a record from before v12 counts as the responder's); the record's shared secret is stored in clear, like the fabric's keys (security model), unless the store seals it (v10's seal mark)
matter_diagnostics v1 a single-row counter table, created and seeded but read by nothing (its typed API is removed in v0.10.0); the facade keeps its counters in matter_settings. Erase seeds its row again, as every row the schema seeds
matter_metadata v1 integer counters: next_fabric_index, event_number_ceiling, since v0.12.0 an ICD node's icd_management.counter, and with Commissioning.RotatingDeviceID the Rotating Device Identifier's rotating_device_id_lifetime_counter, advanced at every advertised commissioning window
matter_settings v1, a column added in v10 string key/value pairs (next section); since v10 the seal mark of a secret setting
matter_persistent_subscriptions v1 unused since v0.3.0; kept so old and new databases have the same schema
matter_group_table v2 (v0.2.0) GroupTable: the endpoints of each group
matter_groupcast_groups v2 the Groupcast cluster's per-group properties
matter_server_subscriptions v2, a column added in v8 the subscriptions of active CASE sessions, to re-establish after a restart; since v8 the exact order they were saved in (save_seq), which the re-establishment walks newest first
matter_ota_default_providers v4 (v0.3.0) the OTA requestor's DefaultOTAProviders
matter_thermostat_presets v5 (v0.8.3) a Thermostat endpoint's presets and active preset handle
matter_doorlock_users, matter_doorlock_credentials, matter_doorlock_schedules v6 (v0.8.4), columns added in v10 a lock endpoint's users, credentials (encrypted) and schedules; since v10 whether a Matter command created a user or credential and made its last change (created_through_matter, modified_through_matter: GetUser and GetCredentialStatus answer its fabric indexes only then; a record seeded through DoorLockConfig.Initial answers them null, a row from before v10 takes 1), and a credential row's seal mark
matter_icd_registrations v7 (v0.12.0) an ICD node's registered Check-In clients per fabric: check-in node id, monitored subject, key, client type; removed with the fabric. Since v0.12.1 the key is sealed at rest (AES-128-GCM under icd_management.key, bound to its row); store.Upgrade seals the keys an earlier release stored in clear. Since v10 the row's seal mark: under store.NewSealed the host's sealer seals the key instead

Tables of endpoint/sqlitestore

Table Holds
matter_endpoints one row per source: its stable key's string form, its scope, its endpoint number and device type
matter_endpoint_allocation the high-water mark of endpoint numbers. A removed source's number is never reused, because a controller caches accessories by number; only the factory reset (endpoint.Store.EraseEndpoints) restarts it, so the node that comes back numbers from 2 as a fresh install

The stable key's string form is the primary key. If a host changes how its key renders, the row is orphaned and the source gets a new endpoint number.

Source: store/schema.sql, store/migrations.go (migrationVersions), store/migrations/v1.up.sql, store/metadata.go (metadataKeyNextFabricIndex), store/settings.go (MetadataKeyEventNumber), endpoint/sqlitestore/schema.sql (matter_endpoints, matter_endpoint_allocation).

Settings keys

matter_settings holds the controller-written attribute values and the facade's own state. A store from store.NewSealed seals the values of the keys that hold secrets — netcomm.wifi.networks, door_lock.credential_key, icd_management.key, the two operational_credentials.pending_noc* keys, commissioning.rotating_device_id.unique_id and every jointfabric.datastore: key — and marks their rows (sealed, v10); the other values stay as they are (sealing at rest). store.seal_canary is reserved: the seal canary NewSealed writes; the Settings methods neither write nor delete it.

Key Written by Holds
basic_information.node_label, basic_information.location the facade the root's NodeLabel and Location as a controller wrote them, the NodeLabel also as Node.SetNodeLabel set it; both in one write
basic_information.configuration_version the facade the root's ConfigurationVersion
basic_information.unique_id the facade UniqueID, derived on the first boot and pinned
commissioning.rotating_device_id.unique_id the facade with Commissioning.RotatingDeviceID: the Rotating Device Identifier's unique id, 16 random bytes in hex, drawn at the first advertised window, sealed under store.NewSealed; its lifetime counter is the matter_metadata counter rotating_device_id_lifetime_counter
bridged_node_label.<key> the facade a bridged endpoint's NodeLabel
bridged_configuration_version.<key> the facade a bridged endpoint's ConfigurationVersion
scenes.<key> the facade a bridged endpoint's scene table
binding.<key>, binding.@<endpoint> the facade an endpoint's Binding list; @ and the number for an endpoint without a stable key
aggregator.forget_pending the facade the Aggregator.Forget batches whose erase is still owed, a JSON list of their key sets; the next New finishes them, and a key added again leaves the record
user_label.root, user_label.aggregator the facade the UserLabel lists of the root and the Aggregator
bridged_user_label.<key> the facade a bridged endpoint's UserLabel list, when its device declares the cluster; a controller's write is stored before it answers, and a refused store write answers FAILURE; a write the server refuses puts the stored list back, and when the store refuses that too, the list the server holds is written when the node stops. Aggregator.Forget erases it
nonvolatile.<key>.<cluster>.<attribute>, nonvolatile.@<endpoint>.<cluster>.<attribute> the facade the value a nonvolatile attribute the module holds was last changed to, the cluster and attribute id in hex: every attribute whose generated definition carries the N quality and write access, not fabric-scoped and not kept under a key of its own above, of a server the module holds — the root's own, not one the host mounts there (Config.RootServers) (ActiveLocale, HourFormat, ActiveCalendarType, TemperatureUnit, NetworkCommissioning's InterfaceEnabled, …) and, on a bridged endpoint, one its device.Device built itself where no declared host port takes the attribute (Device.HoldsAttribute: StartUpOnOff, StartUpCurrentLevel, StartUpColorTemperatureMireds, WindowCovering's Mode, the Thermostat's limits, …). The value is the TLV of the value, hex. Every change is stored, whatever made it. A controller's write is stored before the server takes it: a refused store write answers FAILURE and the value is not in effect, a write the server refuses puts the stored value back, and the value the server holds after it applied the write (WindowCovering's Mode without CalibrationMode under MaintenanceMode, a companion setpoint the write moved) replaces it, so a restart serves what was served. Any other change — a command (SetpointRaiseLower), the host's Set, a companion the server moves — is stored after the server committed it, from the server's change notification; a store that refuses it is logged and the value is written again at the next change of the attribute and when the node stops. A crash between such a commit and its store write leaves the value stored before the change, which the restart serves. Only writes of the same attribute wait for one another (a host's OnWrite veto included). It is restored before the endpoint is served and overrides the declaration's Initial, once per server: a Device the host removes and adds again keeps what it holds and its stored values; one the host forgets (Aggregator.Forget) is let go, its later changes are not stored, and every value stored under its key and its parts' keys is erased, so a device added under the key afterwards starts from its declaration's Initial. A controller's write that reaches a server no longer in its key's place — a Device the host replaced or forgot, answering on the topology the write was resolved on — is not stored. Under the Aggregator a restored StartUp attribute is read back, not applied
gendiag.reboot_count the facade RebootCount: 0 on a database's first boot, then one more per boot
gendiag.operational_ms the facade accumulated operational time (gendiag.operational_hours is read once as its legacy form)
ota_requestor.state store the OTA requestor's state
door_lock.credential_key cluster/lock the key the DoorLock server encrypts credential data with; sealed under store.NewSealed
icd_management.key (store.SettingICDKey) store the key a store without a sealer seals the ICD registrations' keys with; created with the first registration. A store from store.NewSealed creates none (its sealer seals the ICD keys) and seals one an earlier store left
door_lock.saved:<key> store a lock endpoint's records were saved at least once
access_control.extension.<fabric> cluster/core AccessControl's Extension list per fabric
matter.fabric.<fabric>.vid.statement, matter.fabric.<fabric>.vid.vvsc cluster/core (releases before v8) the VID verification statement and VVSC per fabric, hex, as releases before v8 kept them; the data now lives in matter_fabrics (UpdateFabricVIDVerification), store.Upgrade moves every such key into its fabric's columns and deletes it, and nothing writes the keys any more
operational_credentials.pending_noc, operational_credentials.pending_noc_update cluster/core (releases before v8) what an AddNOC (the first key) or an UpdateNOC (the second) of a release before v8 wrote that CommissioningComplete had not committed, as JSON. Since v8 the fabric row carries that state itself (matter_fabrics.pending): an AddNOC inserts its row pending, an UpdateNOC marks it pending with the values it replaced, CommissioningComplete commits it with one write, and a fail-safe's end, a fresh arm and every start roll back each row still pending. A start that finds one of the two keys — a database such a release left in the middle of a commissioning — rolls back exactly what that release's start rolled back (an AddNOC's fabric by its index, or, when the index was never written, the fabric with that id and root key only if it has no identity yet; an UpdateNOC's replaced credentials when the fabric still carries the marker's id and root key) and clears the key; nothing else reads or writes them
basic_information.surface_digest the facade the root's effective surface digest, against which a surface change raises ConfigurationVersion; a change's digests are stored in one write with the ConfigurationVersions it raised, so a refused write stores neither and the next start announces the change again
bridged_surface_digest.<key>, bridged_surface_digest.@<endpoint> the facade a bridged endpoint's (or an unkeyed endpoint's) effective surface digest
endpoint_number_reserved.<key> the facade a removed endpoint's reservation: the stable keys of its tree, whose numbers stay held until Forget
timesync.trusted_time_source, timesync.default_ntp, timesync.time_zone, timesync.dst_offset cluster/core TimeSynchronization's TrustedTimeSource, DefaultNTP, TimeZone and DSTOffset — the four values connectedhomeip persists (TimeSyncDataProvider), under the module's own keys; the offset of the node's UTC over its clock is not stored
general_commissioning.tc_acceptance (store.SettingTermsAcceptance) cluster/core the committed terms-and-conditions acceptance (<version>:<bits>) of GeneralCommissioning's TC feature (node.Commissioning.TermsAndConditions); written at CommissioningComplete or by a SetTCAcknowledgements outside a fail-safe window, deleted with the last fabric, erased by the factory reset
netcomm.wifi.networks cluster/core NetworkCommissioning's committed Wi-Fi networks, each with its SSID and its credentials, as JSON; written at CommissioningComplete on a Wi-Fi node (node.Network.WiFi), before the fabric is committed: a store that refuses it fails CommissioningComplete with nothing committed, and a fabric commit that fails after it writes the previous list back. The credentials are stored in clear, like the fabric's keys, unless the store seals them: whoever reads the database reads the Wi-Fi passphrase (security model)
thermostat_user_interface_configuration.keypad_lockout (thermo.DefaultKeypadLockoutSetting) cluster/thermo ThermostatUserInterfaceConfiguration's KeypadLockout, when the server is given Settings; ThermostatUIConfig.SettingKey names another key, which a second endpoint with the cluster needs
thermostat.suggestions.<key>, thermostat.overridden_suggestion.<key> cluster/thermo (store.ThermostatSuggestionStore) a Thermostat endpoint's ThermostatSuggestions (the TLV of the list, hex) and the UniqueID of the entry a manual override holds (decimal, empty for none), written together, when the server is given ThermostatConfig.SuggestionStore; <key> is the endpoint key the host names, as for its ThermostatPresetStore. A start drops the stored entries that name no preset. Erased with the store
tls.certificates:<key>, tls.endpoints:<key> cluster/tls the certificate tables of TlsCertificateManagement and the provisioned endpoints of TlsClientManagement, when the servers are given a Store; <key> is the server's Key
jointfabric.datastore:<key> cluster/jointfabric the JointFabricDatastore server's record, when it is given a Store; <key> is the server's Key. It carries the joint fabric's group key sets; sealed under store.NewSealed

<key> is the endpoint's stable key in String() form, the same identity endpoint numbers are kept under. Aggregator.Forget deletes, in one DeleteSettings write, every key above kept under a forgotten key — the NodeLabel, the ConfigurationVersion, the scene table, the Binding list, the UserLabel list, the surface digest and the nonvolatile values — so a device added under the key afterwards starts from its declaration. A host that keeps scenes and labels itself sets Config.EndpointState (node.NewEndpointState is the facade's own), and the scenes. and bridged_node_label. keys are then not written.

Store errors

A change a controller causes is stored with the change: the store write comes first, and a refused store answers FAILURE and applies nothing — an attribute write, a scene command's change of the table, a bridged endpoint's NodeLabel. A scene table the store could not read stays unloaded: every scene command answers FAILURE and nothing is stored over the stored table until a read succeeds. The consequences of a change — the OTA requestor's progress, the scenes a group's or a fabric's removal takes along — are applied whatever the store answers, logged when it refuses, and stored with the next change. The rule is stated once, in the package documentation of store.

A host may use the settings table for its own state, as the reference daemon does with blind.position. Pick a prefix that none of the keys above use.

Source: store/settings.go (SettingNodeLabel, SettingLocation, SettingUniqueID, SettingTermsAcceptance), node/persist.go (rootConfigVersionKey, endpointLabelKeyRoot, endpointConfigVersionKey, scenesKeyRoot, bindingKeyRoot, rebootCountSetting, operationalTimeSetting, legacyOperationalHoursSetting), node/nonvolatile.go, device/held.go, node/persist.go (EndpointPersistence, countBoot, loadOperationalTime, storeOperationalTime, bindingKey), node/root.go (rootUserLabelsKey, aggregatorUserLabelsKey), node/user_labels.go (bridgedUserLabelKeyRoot), node/node.go (settingRotatingIDUniqueID), store/ota.go (otaRequestorStateKey), store/doorlock.go (SettingDoorLockCredentialKey, settingDoorLockSaved), store/icd.go, cluster/core/access_control.go (aclExtensionSettingKey), store/schema.go (vidSettingKey), cluster/core/operational_credentials_pending.go (pendingNOCSettingKey, pendingNOCUpdateSettingKey), node/surface_stability.go (rootSurfaceKey, endpointSurfaceKey), node/reserve.go (endpointReservedKeyRoot, forgetPendingKey), cluster/core/time_synchronization_features.go (timeSyncKeyTrustedTimeSource, timeSyncKeyDefaultNTP, timeSyncKeyTimeZone, timeSyncKeyDSTOffset), cluster/core/network_commissioning_wifi.go (wifiNetworksKey), cluster/thermo/thermostatuserinterfaceconfiguration.go (DefaultKeypadLockoutSetting), store/thermostat_suggestions.go (thermostatSuggestionsKeyRoot, thermostatOverrideKeyRoot), cluster/tls/persist.go (settingCertificates, settingEndpoints), cluster/jointfabric/datastore.go (settingPrefix), examples/reference-bridge/persist.go (blindPositionKey).

script/docscheck (TestSettingsKeysDocumented) holds the table to the code: a SetSetting call that states its key as a constant fails the build while the key is not in a table of this page.

What survives a restart

Survives Does not survive
fabrics, NOCs, keys, ACL live PASE and CASE sessions (controllers reconnect, with resumption)
group keys, group table, Groupcast properties the event log's events (their numbers continue past the stored ceiling)
endpoint numbers, labels, ConfigurationVersions, scene tables, bindings, the nonvolatile attributes the module holds (nonvolatile. keys) an open commissioning window (an uncommissioned node opens its own again at Start)
CASE resumption records the diagnostic event ring behind DiagnosticLogs
the subscriptions of active CASE sessions, re-established under their old ids (not on an ICD node, whose controllers re-subscribe on a Check-In)
UniqueID, RebootCount, operational time, OTA default providers
an ICD node's Check-In registrations and ICDCounter

A restart does not re-identify the node: UniqueID is pinned, and fabrics and endpoint numbers are the same.

Source: node/node.go (New), node/node.go (Node.Start), store/schema.sql (matter_server_subscriptions), node/security.go (wireSecurity), bridge/bridge.go (AttachSubscriptionStore), node/config.go (BasicInformation.UniqueID).

The controller database

A controller keeps its state in the same kind of file. The reference controller and the quickstart apply store.Apply (for the settings table) and sqlstore.Apply:

Where Holds
matter_settings controller.ca the CA: root certificate, root key, certificate counter (JSON, matter.js field names)
matter_settings controller.ca.fabric our fabric: fabric id, root node id, IPK, index, label, our key and NOC
matter_settings controller.dcl.trust the DCL trust store (reference controller, with --dcl)
matter_client_values each paired node's attribute values, as TLV
matter_client_versions each stored cluster's DataVersion
matter_client_values, cluster 0xFFFFFFFD each node's ICD Check-In registration: key, pending key, counter state, monitored subject, client type
matter_client_values, cluster 0xFFFFFFFC a node's onboarding code, when kept (Config.KeepOnboardingCodes) or attached: the code, its source, the time, the checks it passed — a secret, like the keys above
matter_client_metadata the registry's marks: sqlstore.seal_scrub_owed while a sealing's scrub of the file has not finished (sqlstore.NewSealed, Store.ScrubOwed), and the seal canary sqlstore.seal_canary, its sealed value in data (v3)

The two controller.ca keys are ca.SettingStore's default; another Key moves both. The controller keeps one CASE resumption record per node in matter_resumption, so a restarted controller resumes instead of running full CASE. With controller.Config.Sealer the CA, the fabric, the resumption records, the group key sets, the kept onboarding codes and the ICD keys are sealed (security).

Source: controller/ca/persist.go (SettingStore, DefaultSettingKey), controller/client/sqlstore/sqlstore.go (Store, New), controller/client/sqlstore/schema.sql (matter_client_values, matter_client_versions, matter_client_metadata), examples/reference-controller/cli/stack.go (dclTrustKey, selfKey, groupKeyPref), examples/reference-controller/README.md (The database), node/client.go (NewStoreResumption).

Schema changes

Each schema ships three ways:

  • Apply runs the whole DDL. It is idempotent and safe on every boot. store.Apply then runs store.Upgrade, which rebuilds what an idempotent CREATE cannot change (the v3 rebuild of matter_group_key_map, v8's added columns) and moves data an earlier release kept elsewhere (the VID settings into matter_fabrics). A host that runs Migrations() with its own tool calls store.Upgrade once after it, for the moves. sqlstore.Apply likewise runs sqlstore.Upgrade, which adds v2's seal mark to matter_client_values and v3's data column, the seal canary's, to matter_client_metadata.
  • Migrations() returns the same schema as versioned steps (v1, v2, …), each with Up and Down, for a host that runs its own migration tool. A released step never changes. Pin len(Migrations()) and the last version, so the next release's new step fails the pin at the dependency bump instead of at a live write. v3's Down is lossy; v8's rolls every pending fabric back first (an uncommitted AddNOC's fabric is deleted, which needs the foreign-key pragma for its cascade) and writes the VID data back into the settings.
  • SchemaFingerprint(db) hashes the module's tables and indexes as SQLite records them. Compare it with the value the CHANGELOG records for the release to know your tables match. A host's own tables and indexes do not change it.
Package Schema/Apply Migrations SchemaFingerprint
store yes yes yes
controller/client/sqlstore yes yes (its own list) yes
endpoint/sqlitestore yes no no

The schemas are independent and can be applied in either order.

Source: store/schema.go (Schema, Apply, Upgrade), store/migrations.go (Migration, Migrations, SchemaFingerprint), controller/client/sqlstore/schema.go (Schema, Apply, Upgrade, Migrations, SchemaFingerprint), endpoint/sqlitestore/sqlitestore.go (Schema, Apply), endpoint/sqlitestore/schema.sql.

Backup

The module ships no backup tool. What a backup has to respect:

  • The file holds private keys. The node's operational keys and the controller's CA key are stored unencrypted, unless the store seals them (store.NewSealed; for a controller controller.Config.Sealer, sealing at rest). The store's documentation leaves file-system protection to the operator. Protect the database and every copy of it like the keys — and, under a sealer, keep the sealing key out of the backup.
  • Copy a consistent state. Stop the node first, or use SQLite's own online mechanisms (VACUUM INTO, the backup API). Copying the file of a running node can catch a write half-done.
  • Run one copy at a time. A restored database is the same node: the same fabrics, the same operational identity. Two running copies answer as one node under one identity.

Source: store/doc.go (package doc, Secrets at rest), store/schema.sql (matter_node_identities), store/seal.go (NewSealed), examples/reference-controller/README.md (The database).