Skip to content

fix(cosmovisor): retry while upgrade-info.json is still empty - #26819

Open
kriss39 wants to merge 1 commit into
cosmos:mainfrom
kriss39:fix/cosmovisor-empty-file-retry
Open

kriss39 wants to merge 1 commit into
cosmos:mainfrom
kriss39:fix/cosmovisor-empty-file-retry

Conversation

@kriss39

@kriss39 kriss39 commented Sep 14, 2026

Copy link
Copy Markdown

Description

fileWatcher.CheckUpdate handles the case where upgrade-info.json has been created but not yet written (#21086) by polling up to 10 × 2 ms for the write to land. The loop's exit condition is inverted:

for range 10 {
    time.Sleep(2 * time.Millisecond)
    stat, err = os.Stat(fw.filename)
    ...
    if stat.Size() == 0 {
        break
    }
}

It breaks out as soon as the file is still empty, so the "wait for the write" path is effectively a single 2 ms retry, and a write that lands 3–20 ms later is missed until the next ticker interval. In the common case that only delays the upgrade by one poll interval; on a slow disk / loaded host the daemon can be killed on the next tick anyway, so this mostly matters for the guarantee the retry loop was meant to provide.

Changes

  • Flip the condition: keep polling while the file is empty, stop as soon as it has content.
  • Regression test TestCheckUpdateWaitsForEmptyFileWrite: starts from an empty file, writes the plan 5 ms later from another goroutine, and asserts CheckUpdate picks it up. Fails on main (Should be true), passes with the fix.
  • cosmovisor CHANGELOG entry.

The retry loop added in cosmos#21487 to wait for a partially written
upgrade-info.json breaks out as soon as the file is *still* empty and keeps
polling once it has content, which is the opposite of the intent. Break
once the size is non-zero.
@greptile-apps

greptile-apps Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

PR author is not in the allowed authors list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant