Speed up race-safe install publication

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Fixed
    • Priority: Major - P3
    • 9.1.0-rc0
    • Affects Version/s: None
    • Component/s: Bazel
    • None
    • Fully Compatible
    • Build OnDeck
    • None
    • None
    • None
    • None
    • None
    • None
    • None

        1. Summary
          SERVER-132885 slowed install targets after a shared convenience-tree race was found. This branch keeps publication race-safe while consolidating each `mongo_install_rule` into one install action, validating destination ownership during analysis, and avoiding unnecessary large-file copies.
        1. Changes
      • `bazel/install_rules/install_rules.bzl`: normalize destinations, assign unique owners, reject exact/prefix/case-insensitive overlaps during analysis, and avoid republishing child install trees from aggregate targets.
      • `bazel/install_rules/install_rules.py`: materialize action outputs with hardlinks where safe, preserve stable Bazel output symlinks, stage shared destinations outside the lock, and publish them with transactional renames and rollback.
      • `bazel/install_rules/README.md`: document the architecture and safety invariants.
      • Added analysis and runtime coverage for collisions, deduplication, symlinks, cross-device fallback, failures, and concurrent publication.
        1. Timing
          These are Bazel profile durations for the install action only; compile and analysis time are excluded.
      Profile Install action Time
      ---:
      A: pre-hermetic container `MongoInstallRule install-dist-test/bin/mongod` 3.127 s
      B: hermetic container change (community) `MongoInstallRule install-dist-test/bin/mongod` 7.283 s
      B: hermetic container change (enterprise, critical path) `MongoInstallRule src/mongo/db/modules/enterprise/install-dist-test/bin/mongoauditdecrypt` 35.596 s
      C: consolidated action before hardlinks `MongoInstallRule install-dist-test/bin/mongod` 86.893 s
      C: consolidated action with hardlinks `MongoInstallRule install-dist-test/bin/mongod` 9.903 s

      The hardlink change reduces the comparable C install action by about 89%. A separate explicit shared-install-environment run measured 2.082 s, but the direct sandbox did not refresh the host convenience mount, so 9.903 s is the primary comparable C result.

        1. Safety
          Exact, prefix, and case-insensitive destination conflicts fail during analysis. Stable output symlinks are hardlinked without dereferencing; unsafe source or sandbox-local symlinks are copied so published trees cannot dangle. Shared publication holds the lock only for final renames and restores the previous destination if interrupted.
        1. Testing
      • `bazel --batch test --config=local //bazel/install_rules:install_rules_script_test` (16/16 passing).
      • `bazel --batch run lint – //bazel/install_rules:install_rules_script_test` (passing targeted rules-lint, Pyright, and ESLint checks).
      • `bazel run format` and `git diff --check` pass.
      • Required Evergreen patch: https://spruce.corp.mongodb.com/version/6a7eb26c19db910007db09a7

            Assignee:
            Daniel Moody
            Reporter:
            Daniel Moody
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: