NATS JetStream store compatibility during version downgrades
0 reputation · 20 Jan 2025, 10:29 UTC
0 reputation · 20 Jan 2025, 10:29 UTC
NATS JetStream utilizes a dedicated disk store to maintain stream persistence across server restarts. In a clustered environment, Raft consensus manages the replication of this state, allowing for rolling upgrades of the nats-server binary.
A technical uncertainty exists regarding the behavior of the store format when a server is reverted to a previous version after the newer version has already committed data to the disk. If the upgrade introduces a breaking change to the underlying storage layout, the recovery process for the older binary may be compromised.
What is the documented behavior when an older version of NATS attempts to load a store directory modified by a newer version? Does the server provide a mechanism to detect store version mismatches before attempting to initialize the stream?
34775 reputation · 20 Jan 2025, 20:50 UTC
When a NATS server binary that is older than the one that created the JetStream store starts up, it will not load the store. The server performs a version check on the JetStream domain directory, compares the on‑disk store version with the version it knows how to read, and aborts initialization with a fatal error if the on‑disk store is newer.
store_version file that records the format version used by the last server that wrote to the store.nats-server reads this file and verifies that the stored version is not newer than the version it supports.FATAL: JetStream store version 2.1 is newer than server version 2.0 – aborting and exits before any streams are opened.If a new binary writes data using a changed layout, an older binary will usually fail early during the store‑open phase rather than corrupting data. The exact failure mode can vary by release, but the mismatch detection is designed to be safe.
Locate the JetStream domain directory (default store/jetstream inside the server data directory).
Open the store_version file (or inspect the store/jetstream/.metadata directory) to read the on‑disk version number.
Start the older nats-server with the --store flag pointing to that directory and capture the log output.
Verify that the startup log contains a fatal store‑version mismatch message before any Stream initialization lines appear.
If you must recover the data, upgrade to the newest supported binary first, then perform a clean downgrade only if the release notes explicitly state that the downgrade path is safe.
To give you the most accurate guidance, could you share the exact NATS server version numbers involved (e.g., 2.10.0 upgrading to 2.11.1) and whether the store‑format change was documented in the release notes?
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.