Skip to content

Add tokio runtime precondition guard to all public sync entry points on EtcdCoordinator #150

Description

@coderabbitai

Summary

Only connect() and status() on EtcdCoordinator (in crates/gossip-coordination-etcd/src/backend/coordinator.rs) currently enforce the runtime precondition guard:

assert!(
    tokio::runtime::Handle::try_current().is_err(),
    "connect() must not be called from within an active Tokio runtime"
);

All other public sync entry points that reach self.runtime.block_on() are missing this guard. Callers invoking these methods from an async context will deadlock inside Tokio instead of receiving the explicit contract error documented on the type.

Affected methods

  • etcd_get
  • etcd_txn
  • etcd_lease_grant
  • etcd_lease_keep_alive_once
  • etcd_lease_revoke
  • list_active_runs_into
  • gc_stale_initializing_runs_into
  • Sync trait implementations backing create_run, renew, and related operations

Proposed fix

Add the same assertion at the top of each affected method, before any use of self.runtime or block_on, mirroring the existing connect()/status() semantics.

Background

Deferred from PR #148 (module split refactor) to keep that PR focused. See the review comment: #148 (comment)

Requested by: @ahrav

Activity

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions