Skip to content

fix(device): a failed_and_migrated device is never brought back - #1706

Open
wmousa wants to merge 1 commit into
mainfrom
fix/failed-and-migrated-is-terminal
Open

wmousa wants to merge 1 commit into
mainfrom
fix/failed-and-migrated-is-terminal

Conversation

@wmousa

@wmousa wmousa commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Problem

failed_and_migrated means a device's data was moved elsewhere and its place in the cluster given up. A replacement enters as a new device record (new_device_from_failed); the old record is not meant to come back. Nothing enforced that:

  • device_set_state restricted the exits of failed only.
  • storage_node_monitor.readmit_devices_after_node_online, which runs when a node is cleared from UNREACHABLE/DOWN back to ONLINE, skipped devices that were online, removed or failed and set every other device ONLINE, including failed_and_migrated and new ones.

What happened on the lab

3 nodes, 1+1, fio running. Several devices had been failed and migrated out earlier. While one node was restarting, another was marked unreachable for a moment and then cleared back to ONLINE:

20:22:27 Storage node status changed from: unreachable to: online
20:22:27 Device status changed from: failed_and_migrated to: online      (x3)
20:22:32 error_open                                                      (x3)
20:22:32 Device status changed from: online to: unavailable -> removed   (x3)
20:22:34 Cluster status changed from degraded to suspended
[storage-node-monitor] Re-admitting device f57417f1-... (was failed_and_migrated) after node 7786b344-... cleared to ONLINE

The drives were not there, SPDK could open none of them, and with the peer still restarting the cluster was suspended and fio failed.

Fix

  • device_set_state refuses every transition out of failed_and_migrated, whatever the cause. The record also no longer walks to removed when a removal event arrives for it.
  • The re-admit names the states it leaves alone (_NOT_READMITTED): online, removed, failed, failed_and_migrated and new. A new device is not part of the cluster yet and has no place in the cluster map to be re-admitted to.

Tests

tests/integration/test_failed_and_migrated_is_final.py, against the real database: the re-admit touches only the device the outage made unavailable; no state and no cause takes a device out of failed_and_migrated; failed still reaches failed_and_migrated; a forced remove leaves the record as it is.

Unit tier locally: no new failures against main. The integration tier needs Docker and was not run locally; CI runs it.

Systemic cause

Device states are guarded by per-state if blocks in device_set_state and by exclusion lists at the callers. A state nobody listed is writable from everywhere, and a caller that lists what to skip silently includes every state added later. A durable fix is one table of allowed transitions (from, to, cause) that device_set_state consults, with callers stating which states they act on instead of which they skip. Not done here.

🤖 Generated with Claude Code

failed_and_migrated says a device's data was moved elsewhere and its place
in the cluster given up; a replacement enters as a new record
(new_device_from_failed). Nothing enforced that. device_set_state treated
only "failed" as a state with restricted exits, and the node monitor's
re-admit of a recovered node's devices skipped the online, removed and
failed ones and set every other device ONLINE.

On the lab a node was marked unreachable for a moment while a peer
restarted, and was cleared back to ONLINE. The monitor set the three
devices of that node that had been migrated out ONLINE again. SPDK could
open none of them, each was walked through unavailable to removed, and with
the peer still restarting the cluster was suspended and client IO failed.

device_set_state now refuses every transition out of failed_and_migrated,
whatever the cause, and the re-admit names the states it leaves alone,
failed_and_migrated and new (a device that is not part of the cluster yet)
among them.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@github-actions github-actions Bot added the target/main Targets the development branch label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

target/main Targets the development branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant