Mail delivered during the day lost after docker compose up -d pulled 1.0.0 against a 0.16.27 store (store reverted to last clean shutdown)

Issue Description

Title: Mail delivered during the day lost after docker compose up -d pulled 1.0.0 against a 0.16.27 store (store reverted to last clean shutdown)

Expected Behavior

All email received from last clean shutdown to time of migration should still be present.

Actual Behavior

Lost email received from last clean shutdown to time of migration on 27 October 2026

Relevant Log Output

debian@mx:~$ sudo ls -la --time-style=full-iso /opt/stalwart-mail/data | grep -i -e LOG -e ‘.log’
sudo grep -i -e ‘recover’ -e ‘WAL’ -e ‘corrupt’ /opt/stalwart-mail/data/LOG* | head -60
-rw-r–r-- 1 2000 2000 24860 2026-10-27 20:37:24.124281427 +0000 005939.log
-rw-r–r-- 1 2000 2000 305608 2026-10-27 20:37:24.124281427 +0000 LOG
-rw-r–r-- 1 2000 2000 229547 2026-10-27 20:19:49.295879484 +0000 LOG.old.1793132395918031
-rw-r–r-- 1 2000 2000 235218 2026-10-27 20:19:56.239856100 +0000 LOG.old.1793132409257976
-rw-r–r-- 1 2000 2000 229547 2026-10-27 20:20:09.575811171 +0000 LOG.old.1793132442920914
-rw-r–r-- 1 2000 2000 211797 2026-10-27 20:21:48.111478451 +0000 LOG.old.1793132512209289
/opt/stalwart-mail/data/LOG:2026/10/27-20:21:52.210304 139853507724928 Options.track_and_verify_wals_in_manifest: 0
/opt/stalwart-mail/data/LOG:2026/10/27-20:21:52.210305 139853507724928 Options.track_and_verify_wals: 0
/opt/stalwart-mail/data/LOG:2026/10/27-20:21:52.210330 139853507724928 Options.wal_dir:
/opt/stalwart-mail/data/LOG:2026/10/27-20:21:52.210332 139853507724928 Options.WAL_ttl_seconds: 0
/opt/stalwart-mail/data/LOG:2026/10/27-20:21:52.210333 139853507724928 Options.WAL_size_limit_MB: 0
/opt/stalwart-mail/data/LOG:2026/10/27-20:21:52.210345 139853507724928 Options.wal_recovery_mode: 2
/opt/stalwart-mail/data/LOG:2026/10/27-20:21:52.210355 139853507724928 Options.wal_filter: None
/opt/stalwart-mail/data/LOG:2026/10/27-20:21:52.210356 139853507724928 Options.avoid_flush_during_recovery: 0
/opt/stalwart-mail/data/LOG:2026/10/27-20:21:52.210359 139853507724928 Options.manual_wal_flush: 0
/opt/stalwart-mail/data/LOG:2026/10/27-20:21:52.210360 139853507724928 Options.wal_compression: 0
/opt/stalwart-mail/data/LOG:2026/10/27-20:21:52.210362 139853507724928 Options.background_close_inactive_wals: 0
/opt/stalwart-mail/data/LOG:2026/10/27-20:21:52.210377 139853507724928 Options.best_efforts_recovery: 0
/opt/stalwart-mail/data/LOG:2026/10/27-20:21:52.210389 139853507724928 Options.wal_write_temperature: kUnknown
/opt/stalwart-mail/data/LOG:2026/10/27-20:21:52.210397 139853507724928 Options.max_total_wal_size: 0
/opt/stalwart-mail/data/LOG:2026/10/27-20:21:52.210448 139853507724928 Options.wal_bytes_per_sync: 1048576
/opt/stalwart-mail/data/LOG:2026/10/27-20:21:52.210729 139853507724928 [db/version_set.cc:6116] Recovering from manifest file: /var/lib/stalwart/MANIFEST-005923
/opt/stalwart-mail/data/LOG:2026/10/27-20:21:52.269078 139853507724928 [db/version_set.cc:6174] Recovered from manifest file:/var/lib/stalwart/MANIFEST-005923 succeeded,manifest_file_number is 5923, next_file_number is 5928, last_sequence is 45809363, log_number is 5911,prev_log_number is 0,max_column_family is 26,min_log_number_to_keep is 5911
/opt/stalwart-mail/data/LOG:2026/10/27-20:21:52.270018 139853507724928 EVENT_LOG_v1 {“time_micros”: 1793132512270006, “job”: 1, “event”: “recovery_started”, “wal_files”: [5922]}
/opt/stalwart-mail/data/LOG:2026/10/27-20:21:52.270025 139853507724928 [db/db_impl/db_impl_open.cc:1379] Recovering log #5922 mode 2
/opt/stalwart-mail/data/LOG:2026/10/27-20:21:52.271050 139853507724928 [db/db_impl/db_impl_open.cc:1353] Recovered to log #5922 next seq #45810066
/opt/stalwart-mail/data/LOG:2026/10/27-20:21:52.300559 139853507724928 EVENT_LOG_v1 {“time_micros”: 1793132512300555, “job”: 1, “event”: “recovery_finished”, “status”: “OK”}
/opt/stalwart-mail/data/LOG:Cumulative WAL: 0 writes, 0 syncs, 0.00 writes per sync, written: 0.00 GB, 0.00 MB/s
/opt/stalwart-mail/data/LOG:Interval WAL: 0 writes, 0 syncs, 0.00 writes per sync, written: 0.00 GB, 0.00 MB/s
/opt/stalwart-mail/data/LOG:Cumulative WAL: 43 writes, 0 syncs, 43.00 writes per sync, written: 0.00 GB, 0.00 MB/s
/opt/stalwart-mail/data/LOG:Interval WAL: 43 writes, 0 syncs, 43.00 writes per sync, written: 0.00 GB, 0.00 MB/s
/opt/stalwart-mail/data/LOG.old.1793132395918031:2026/10/27-20:19:48.940938 139933361649856 Options.track_and_verify_wals_in_manifest: 0
/opt/stalwart-mail/data/LOG.old.1793132395918031:2026/10/27-20:19:48.940939 139933361649856 Options.track_and_verify_wals: 0
/opt/stalwart-mail/data/LOG.old.1793132395918031:2026/10/27-20:19:48.940965 139933361649856 Options.wal_dir:
/opt/stalwart-mail/data/LOG.old.1793132395918031:2026/10/27-20:19:48.940967 139933361649856 Options.WAL_ttl_seconds: 0
/opt/stalwart-mail/data/LOG.old.1793132395918031:2026/10/27-20:19:48.940968 139933361649856 Options.WAL_size_limit_MB: 0
/opt/stalwart-mail/data/LOG.old.1793132395918031:2026/10/27-20:19:48.940980 139933361649856 Options.wal_recovery_mode: 2
/opt/stalwart-mail/data/LOG.old.1793132395918031:2026/10/27-20:19:48.940989 139933361649856 Options.wal_filter: None
/opt/stalwart-mail/data/LOG.old.1793132395918031:2026/10/27-20:19:48.940990 139933361649856 Options.avoid_flush_during_recovery: 0
/opt/stalwart-mail/data/LOG.old.1793132395918031:2026/10/27-20:19:48.940993 139933361649856 Options.manual_wal_flush: 0
/opt/stalwart-mail/data/LOG.old.1793132395918031:2026/10/27-20:19:48.940994 139933361649856 Options.wal_compression: 0
/opt/stalwart-mail/data/LOG.old.1793132395918031:2026/10/27-20:19:48.940995 139933361649856 Options.background_close_inactive_wals: 0
/opt/stalwart-mail/data/LOG.old.1793132395918031:2026/10/27-20:19:48.941014 139933361649856 Options.best_efforts_recovery: 0
/opt/stalwart-mail/data/LOG.old.1793132395918031:2026/10/27-20:19:48.941022 139933361649856 Options.wal_write_temperature: kUnknown
/opt/stalwart-mail/data/LOG.old.1793132395918031:2026/10/27-20:19:48.941029 139933361649856 Options.max_total_wal_size: 0
/opt/stalwart-mail/data/LOG.old.1793132395918031:2026/10/27-20:19:48.941037 139933361649856 Options.wal_bytes_per_sync: 1048576
/opt/stalwart-mail/data/LOG.old.1793132395918031:2026/10/27-20:19:48.941289 139933361649856 [db/version_set.cc:6116] Recovering from manifest file: /var/lib/stalwart/MANIFEST-005873
/opt/stalwart-mail/data/LOG.old.1793132395918031:2026/10/27-20:19:49.011475 139933361649856 [db/version_set.cc:6174] Recovered from manifest file:/var/lib/stalwart/MANIFEST-005873 succeeded,manifest_file_number is 5873, next_file_number is 5878, last_sequence is 45809347, log_number is 5858,prev_log_number is 0,max_column_family is 26,min_log_number_to_keep is 5858
/opt/stalwart-mail/data/LOG.old.1793132395918031:2026/10/27-20:19:49.012434 139933361649856 EVENT_LOG_v1 {“time_micros”: 1793132389012422, “job”: 1, “event”: “recovery_started”, “wal_files”: [5872]}
/opt/stalwart-mail/data/LOG.old.1793132395918031:2026/10/27-20:19:49.012440 139933361649856 [db/db_impl/db_impl_open.cc:1379] Recovering log #5872 mode 2
/opt/stalwart-mail/data/LOG.old.1793132395918031:2026/10/27-20:19:49.012494 139933361649856 [db/db_impl/db_impl_open.cc:1353] Recovered to log #5872 next seq #45809352
/opt/stalwart-mail/data/LOG.old.1793132395918031:2026/10/27-20:19:49.066792 139933361649856 EVENT_LOG_v1 {“time_micros”: 1793132389066782, “job”: 1, “event”: “recovery_finished”, “status”: “OK”}
/opt/stalwart-mail/data/LOG.old.1793132395918031:Cumulative WAL: 0 writes, 0 syncs, 0.00 writes per sync, written: 0.00 GB, 0.00 MB/s
/opt/stalwart-mail/data/LOG.old.1793132395918031:Interval WAL: 0 writes, 0 syncs, 0.00 writes per sync, written: 0.00 GB, 0.00 MB/s
/opt/stalwart-mail/data/LOG.old.1793132409257976:2026/10/27-20:19:55.919653 139818531981504 Options.track_and_verify_wals_in_manifest: 0
/opt/stalwart-mail/data/LOG.old.1793132409257976:2026/10/27-20:19:55.919655 139818531981504 Options.track_and_verify_wals: 0
/opt/stalwart-mail/data/LOG.old.1793132409257976:2026/10/27-20:19:55.919683 139818531981504 Options.wal_dir:
/opt/stalwart-mail/data/LOG.old.1793132409257976:2026/10/27-20:19:55.919685 139818531981504 Options.WAL_ttl_seconds: 0
/opt/stalwart-mail/data/LOG.old.1793132409257976:2026/10/27-20:19:55.919686 139818531981504 Options.WAL_size_limit_MB: 0
/opt/stalwart-mail/data/LOG.old.1793132409257976:2026/10/27-20:19:55.919699 139818531981504 Options.wal_recovery_mode: 2
/opt/stalwart-mail/data/LOG.old.1793132409257976:2026/10/27-20:19:55.919709 139818531981504 Options.wal_filter: None
/opt/stalwart-mail/data/LOG.old.1793132409257976:2026/10/27-20:19:55.919710 139818531981504 Options.avoid_flush_during_recovery: 0
/opt/stalwart-mail/data/LOG.old.1793132409257976:2026/10/27-20:19:55.919714 139818531981504 Options.manual_wal_flush: 0
/opt/stalwart-mail/data/LOG.old.1793132409257976:2026/10/27-20:19:55.919715 139818531981504 Options.wal_compression: 0
/opt/stalwart-mail/data/LOG.old.1793132409257976:2026/10/27-20:19:55.919716 139818531981504 Options.background_close_inactive_wals: 0
/opt/stalwart-mail/data/LOG.old.1793132409257976:2026/10/27-20:19:55.919726 139818531981504 Options.best_efforts_recovery: 0
debian@mx:~$

Stalwart Version

v1.x

Installation Method

Docker

Database Backend

RocksDB

Blob Storage

RocksDB

Search Engine

Internal

Directory Backend

Internal

Additional Context

Setup: Docker Compose, single node, RocksDB, Stalwart 0.16.27, image tag :latest, host networking. A nightly cold backup (docker compose stop, restic, start) runs at about 03:31 UTC.

Timeline (UTC, 27 Oct 2026):

03:23 last message stored before the backup (INBOX UID 6098).
03:31 backup stops/restarts the container (about 1s).
03:24–20:10: dozens of messages accepted from our gateway (250 2.0.0 Message queued) and visible in IMAP clients (eM Client online all day).
~20:19: docker compose pull && up -d on :latest, which now resolves to 1.0.0. 1.0.0 logged “data store was created by a Stalwart version prior to 1.0 and cannot be opened” repeatedly and I stopped it. I then pinned v0.16.27 and restarted.
20:21: cold backup of the store. INBOX had 5324 messages and UIDNEXT 6099, with one message dated 27 Oct (03:23). All folders and all accounts lacked the rest of the day’s mail. An isolated restore of that snapshot showed the same.
eM Client’s local cache still held the missing mail. After I re-uploaded it, UIDs 6099/6100 were reused (same UIDVALIDITY).
Afterwards I migrated with stalwart-migrate to 1.0.0 with no errors. The migration isn’t the cause, since the snapshot predates it.

Observation: the store state at 20:21 equals the state at the last clean shutdown (03:31), including UID counters.

Questions:

Does 0.16.27 on RocksDB rely on a clean shutdown/flush for durability of recent writes?
Can 1.0.0 booting against a 0.16 RocksDB directory discard or alter recent WAL/memtable data before the schema check?
Anything else that would revert counters?

RocksDB LOG excerpt: (paste output of check 1)

Possibly related: Missing Emails after v1.0.0 migration, where recent mail was missing on all accounts after migrating from 0.16.27.

I have reviewed the documentation and FAQ and confirm that my issue is NOT addressed there.

on

I have searched this support forum (open and closed topics) and confirm this is not a duplicate.

on

I understand that topics in this category are triaged by a bot first but a human reply will follow up. If I’d prefer a human-only reply, I’ll add the no-ai tag to my topic.

on

I can’t confirm a cause from the docs or source, but I can answer your three questions as far as they go.

Does 1.0.0 alter data before the schema check? The check I found doesn’t write to an existing store. In crates/common/src/manager/schema.rs, verify_schema_version reads the schema version key. For a pre-1.0 store it returns the “prior to 1.0 … cannot be opened” startup error. The only write is write_schema_version, and that runs only when the store looks like a new install. A store with queue, report or property data is not treated as new. I haven’t traced everything 1.0 does before this check, such as opening RocksDB itself. Opening RocksDB replays the WAL, but that replay preserves recent writes. It doesn’t discard them.

Does 0.16 on RocksDB need a clean shutdown for durability? I found nothing in the docs saying so. Your LOG excerpt also shows normal crash recovery working. wal_recovery_mode: 2 is point-in-time recovery, and the log shows Recovering log #5922, then recovery_finished, status: OK. Replaying the WAL is exactly what RocksDB does after an unclean stop, so a clean shutdown shouldn’t be required.

What else could revert counters? Your LOG points at something other than the migration or WAL handling.

  • Each restart’s manifest shows a last_sequence of about 45,809,3xx, and the 20:21 recovery only reached next seq #45810066. That is roughly 700 writes of recent activity. A day of dozens of delivered messages, plus indexing and changelog writes, should look larger than that. This fits the data directory holding an older state than you expect, rather than a replay that lost data.
  • The log paths show /var/lib/stalwart/MANIFEST-... inside the container, while the host path is /opt/stalwart-mail/data. Check that the bind mount or volume the container used during the day is the same one you inspected. Compare it against docker inspect for the mounts of the running 0.16.27 container.
  • Check whether the 03:31 backup job could have written back to the data directory. Examples are a restic restore, an rsync in the wrong direction, or a snapshot-based mount. Also check for a second container or volume with the same name.
  • Look at the earlier LOG.old.* files from before 20:19, if any exist. They would show the last open before the day’s mail and its sequence number. Compare that with the 03:31 state.

If the mail really was only in the live store and the store was reset before 20:21, only your restic snapshots or the eM Client cache can recover it. Keep the 20:21 snapshot and the current 0.16 directory untouched for a human to look at.

For the future, 1.0 can’t open a 0.16 store in place, so don’t use :latest for a store that hasn’t been migrated. Pin the tag and follow the upgrade guide to run stalwart-migrate into a new, empty 1.0 store. Stop 0.16 before the final run.

This is an automated reply from the Stalwart Help Bot. Other community members may follow up if this answer is incomplete or wrong.

0.16 doesn’t depend on a clean shutdown for recent writes. Every write goes to the RocksDB write-ahead log before it’s acknowledged, and the next start replays that log, so a container stop, a kill or a crash of the process loses nothing; only a power loss or kernel crash can drop the last unsynced writes. Nothing in 0.16 winds UID counters back either.

1.0.0 doesn’t change a 0.16 store before refusing it. It opens the database (which replays the log like any start), looks for the schema version, finds none and exits. Opening can’t remove writes that are already in the log or the data files, and both versions open RocksDB with the same options at the same /var/lib/stalwart path.

Your LOG points the same way. The first 1.0.0 start at 20:19:48 replayed a write-ahead log holding five writes (last_sequence is 45809347, then next seq #45809352). 0.16 doesn’t flush that log when it stops, so a day of mail written to this directory since 03:31 would normally show up there as a much longer replay. It looks as if the server eM Client talked to all day wasn’t writing into /opt/stalwart-mail/data.

The file timestamps would settle it:

sudo ls -la --time-style=full-iso /opt/stalwart-mail/data | sort -k6,7

If no .sst or .log file there was modified between 03:31 and 20:19, nothing reached that directory during the day, and the next thing to look at is which mount the container started at 03:31 actually had (docker compose start reuses the existing container as it was created, while up -d recreates it from the current compose file).