Skip to content

[Bug]: MongoDB lease-release UT can fail on unrelated port occupancy #28882

Closed

Description

@XuPeng-SH

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Branch Name

main

Commit ID

b33b063

Other Environment Information

Actual Behavior

TestMongoDBLocalE2EPortPlanReleasesLeaseAfterParentDeath failed with:
port lease remained after parent death: [mongodb-ci] ERROR: MO_MONGODB_LOG_PORT_BASE is not available on this host

The explicit-base allocation path acquires the flock lease first, then probes all 80 ports. It reports already leased if flock acquisition fails, but reports the observed not available error after the lock was acquired and a bind probe failed. Therefore this CI failure does not show that the parent-death lease remained held. The probe does not identify which port was unavailable, so the exact competing socket/process is unknown.

Expected Behavior

The parent-death test should assert the flock-release invariant directly and deterministically, independent of whether arbitrary host ports happen to be available. Port-block availability should remain a separate allocation concern, with actionable diagnostics when a requested block is unavailable.

Steps to Reproduce

  1. Run TestMongoDBLocalE2EPortPlanReleasesLeaseAfterParentDeath from ./test/mongodb in UT Coverage mode.
  2. The test selects an 80-port block, starts a held port-plan process using a test-local lease directory, kills its Bash parent, then retries the full port planner for the same block for up to three seconds.
  3. If any port in that block is unavailable during the retries, the test reports that the lease remained, even when the flock itself can be reacquired. This is timing/host-port dependent and may not reproduce on every run.

Additional Information

  • The test supplies MO_MONGODB_PORT_LEASE_DIR under t.TempDir(), so it does not share the default host-wide lease namespace with normal MongoDB E2E runs.
  • port_block_is_available binds and closes each socket; it is not the lease oracle and cannot guarantee the block remains free.
  • The test/helper were introduced in merged PR test: add MongoDB and UUID issue regressions #27516. Preserve the host-wide lease behavior that prevents real concurrent E2E port allocation; fix the test contract rather than weakening or removing that protection.
  • Root source: test/mongodb/mongodb_e2e_local_test.go and optools/mongodb_ci.bash.

Activity

  1. self-assigned this
    on Sep 14, 2026
  2. added a commit that references this issue on Sep 15, 2026
    6753979
  3. added 2 commits that reference this issue on Sep 17, 2026
    0c1b164
    a08f692
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions