Skip to content

[Reliability] NativeClient::ensureNetwork leaves inconsistent state on partial initialization #47

Description

@s2x

Context / Problem

If fdb_setup_network() succeeds but pthread_create (or the dlopen/dlsym steps) subsequently throws, networkStarted stays false even though the network was already set up, and the shutdown handler is never registered:

src/NativeClient.php:210-248

A later ensureNetwork() then calls fdb_setup_network() a second time (error: network already set up), and the network thread may never be joined at shutdown — a wedged, unrecoverable state.

Affected files / locations

  • src/NativeClient.php:210-266

Proposed approach

Track the fact that fdb_setup_network() has already succeeded separately from full readiness, and on partial-initialization failure either clean up consistently or record state so the object is not left in a half-initialized condition that breaks retry and shutdown.

Acceptance Criteria

  • Documentation updated/added
  • Unit test(s) added simulating a failure after setup_network and asserting consistent state / no double setup
  • Functional test(s) added covering network lifecycle recovery
  • Changelog entry added
  • Post-implementation comment posted on this issue describing what was changed

Severity

Low

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions