fix: retry mkfs on next reconciliation if interrupted#481
fix: retry mkfs on next reconciliation if interrupted#481LoneExile wants to merge 1 commit intoLINBIT:masterfrom
Conversation
Both MkfsUtils.makeFileSystemOnMarked() and DrbdLayer.condInitialOrSkipSync() clear their one-shot gate flags before mkfs runs. If mkfs is interrupted (timeout or failure while the satellite stays running), the flags are already cleared and mkfs is never retried, leaving the DRBD device without a filesystem and the volume stuck in FailedMount. Move both flags to after mkfs succeeds: - MkfsUtils: move disableCheckFileSystem() from before the mkfs loop to after it completes. If mkfs throws, the exception exits the method before the flag is cleared, so the next reconciliation retries. - DrbdLayer: move unsetCreatePrimary() from before the mkfs block to after it completes. This keeps the createPrimary gate open on failure so the DRBD path re-enters on the next device manager run. The existing blkid check (hasFileSystem) already guards against reformatting volumes that have a filesystem, so successfully formatted volumes from a partial run are not reformatted.
|
Honestly I am not sure what to make of this. Why should a second attempt succeed if the first one failed? Besides, we are about to improve the timeout handling for |
|
The timeout fix would cover the most common trigger, but the underlying issue remains if mkfs is interrupted for any reason while the satellite stays running (transient I/O error, OOM-killed child process, etc.) the one-shot flags are already cleared and the volume is stuck forever. only a satellite restart recovers it. This PR just makes flag clearing conditional on success. no behavior change when mkfs succeeds, safe retry on next reconciliation when it doesn't (guarded by blkid) Happy to wait or adapt if you'd prefer to land the timeout fix first |
Problem
When
mkfsis interrupted during initial volume provisioning (e.g., timeout on large volumes, or transient failure while the satellite stays running), the DRBD device is left without a filesystem. The volume appears successfully provisioned but gets stuck in a permanentFailedMountloop becausefsckfails on the unformatted device (exit code 8: "Bad magic number in super-block").This does not self-heal because two one-shot gate flags —
checkFileSystemandcreatePrimary— are cleared before their respective mkfs blocks run. If mkfs throws, both flags are alreadyfalseand mkfs is never retried on subsequent reconciliations.true(in-memory)StltRscDfnApiCallHandlerfalsefalsefalsefalseRoot Cause
Flag 1:
checkFileSysteminMkfsUtils.makeFileSystemOnMarked()disableCheckFileSystem()is called at line 136 ofMkfsUtils.java, before the mkfs loop begins. If any mkfs call throwsStorageException(timeout or failure), the flag is already cleared and the next reconciliation skips the entire block.checkFileSystemis a plainbooleanfield inAbsRscData.java(line 59), initialized totruein the constructor (line 92)trueon satellite restartFlag 2:
createPrimaryinDrbdLayer.condInitialOrSkipSync()rsc.unsetCreatePrimary()is called at line 1773 ofDrbdLayer.java, before bothsetResourceUpToDate()and the mkfs block. After clearing:PROP_PRIMARY_SETis already set by controller → Branch A (request primary) is skippedcreatePrimaryisfalse→ Branch B (go primary + mkfs) is skippedEven if
checkFileSystemwere fixed independently, this outer gate blocks re-entry to the DRBD mkfs path.createPrimaryis a plainbooleanfield inResource.java(line 86), defaultfalseStltRscDfnApiCallHandler.setCreatePrimary()(line 70) after satellite requests primaryTimeout context
The default external command timeout is 45 seconds (
ChildProcessHandler.java, line 20). For large volumes (100+ GB), mkfs can exceed this timeout (see #371).Fix
Move both flags to after their respective mkfs blocks complete successfully. If mkfs throws, the exception exits the method before the flag is cleared, so the next reconciliation retries.
MkfsUtils.java: MovedisableCheckFileSystem()from line 136 (before the mkfs loop) to after the loop completes (line 253 in the patched file).DrbdLayer.java: MoveunsetCreatePrimary()from line 1773 (before the mkfs/sync block) to after it completes (line 1797 in the patched file).Safety
blkidcheck inhasFileSystem()(MkfsUtils.java line 70) prevents reformatting volumes that already have a filesystem — partially completed multi-volume runs are safesetResourceUpToDate()(initial sync trigger) may run again on retry; DRBD handles redundant primary/secondary transitions gracefullyRelated
StorageException: Failed to mkfs; resource stuck InUse, not demoted to secondary after mkfs failure, volume left without filesystem