Skip to content

Set libgit2 server timeouts to prevent hung git fetches - #996

Merged
bdunne merged 1 commit into
ManageIQ:masterfrom
Fryguy:fix_rugged_fetch_timeout
Oct 7, 2026
Merged

bdunne merged 1 commit into
ManageIQ:masterfrom
Fryguy:fix_rugged_fetch_timeout

Conversation

@Fryguy

@Fryguy Fryguy commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

A stalled SSH fetch via Rugged holds the GVL indefinitely, freezing all Ruby threads including the rufus scheduler. Confirmed in production: the process hung mid-fetch with no further output from any thread, including the $stdout.write-based heartbeat, until the pod was restarted.

libgit2 1.7+ supports GIT_OPT_SET_SERVER_CONNECT_TIMEOUT and GIT_OPT_SET_SERVER_TIMEOUT but Rugged::Settings does not yet expose them. Call git_libgit2_opts directly via Fiddle at boot to set both to 5 minutes. Enum values verified against libgit2 1.9.6 (bundled in rugged 1.9.6); confirm against the bundled version if upgrading.

Once a Rugged PR lands to add these options to rugged_settings.c, the Fiddle workaround can be replaced with:

  Rugged::Settings["server_connect_timeout"] = timeout_ms
  Rugged::Settings["server_timeout"]         = timeout_ms

@bdunne Please review. I've created a Rugged PR at libgit2/rugged#1015 but it's waiting on review, and I'd like to get this temp fix in to see if it even works.

A stalled SSH fetch via Rugged holds the GVL indefinitely, freezing all
Ruby threads including the rufus scheduler. Confirmed in production: the
process hung mid-fetch with no further output from any thread, including
the $stdout.write-based heartbeat, until the pod was restarted.

libgit2 1.7+ supports GIT_OPT_SET_SERVER_CONNECT_TIMEOUT and
GIT_OPT_SET_SERVER_TIMEOUT but Rugged::Settings does not yet expose
them. Call git_libgit2_opts directly via Fiddle at boot to set both
to 5 minutes. Enum values verified against libgit2 1.9.6 (bundled in
rugged 1.9.6); confirm against the bundled version if upgrading.

Once a Rugged PR lands to add these options to rugged_settings.c, the
Fiddle workaround can be replaced with:
  Rugged::Settings["server_connect_timeout"] = timeout_ms
  Rugged::Settings["server_timeout"]         = timeout_ms
@Fryguy Fryguy added the bug label Oct 7, 2026
@bdunne
bdunne merged commit 8ed0fcc into ManageIQ:master Oct 7, 2026
3 checks passed
@Fryguy
Fryguy deleted the fix_rugged_fetch_timeout branch October 7, 2026 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants