• Type: Bug
    • Resolution: Unresolved
    • Priority: Minor - P4
    • None
    • Affects Version/s: 9.0.2
    • Component/s: None
    • None
    • ALL
    • Hide

      1. Start MongoDB Community Server 9.0.2 on a fresh disposable dbpath, bound only to localhost:
         mongod.exe --dbpath=<fresh-empty-local-dbpath> --bind_ip=127.0.0.1 --port=27902

      2. Install PyMongo:
         python -m pip install pymongo==4.18.2

      3. Extract the attached ZIP and run:
         python race_probe.py

         The script drops and recreates only constraint_repro.race_probe. It creates a strict/warn collection with validator {v:"ok"}, prepares it for constraint validation, inserts 500,000 valid synthetic documents, starts the collMod upgrade to constraint/error, and after 50 ms updates _id:0 to v:"bad".

      4. Inspect the upgrade_race JSONL event. In the attached three-run trace, upgrade.reply.ok is 1, writer.success is 1, invalid_count is 1, and the final options show validationLevel:"constraint" and validationAction:"error". Subsequent invalid insert and update attempts fail with code 121. A preexisting-invalid control in the same script rejects the upgrade with code 12370902. Inspect these output fields; script exit status alone does not prove the race occurred.

      5. Optional timing control: On a separate disposable 9.0.2 instance at 127.0.0.1:27913 started with --setParameter enableTestCommands=1, run:
         python race_determinism/failpoint_barrier_probe.py
         The attached failpoint-barrier-evidence.jsonl shows the update completing while the actual upgrade scan is paused.

      6. The attached race_impact_validation/evidence.jsonl records a separate clean-restart test in which the invalid document and constraint/error options persisted.

      Show
      1. Start MongoDB Community Server 9.0.2 on a fresh disposable dbpath, bound only to localhost:    mongod.exe --dbpath=<fresh-empty-local-dbpath> --bind_ip=127.0.0.1 --port=27902 2. Install PyMongo:    python -m pip install pymongo==4.18.2 3. Extract the attached ZIP and run:    python race_probe.py    The script drops and recreates only constraint_repro.race_probe. It creates a strict/warn collection with validator {v:"ok"}, prepares it for constraint validation, inserts 500,000 valid synthetic documents, starts the collMod upgrade to constraint/error, and after 50 ms updates _id:0 to v:"bad". 4. Inspect the upgrade_race JSONL event. In the attached three-run trace, upgrade.reply.ok is 1, writer.success is 1, invalid_count is 1, and the final options show validationLevel:"constraint" and validationAction:"error". Subsequent invalid insert and update attempts fail with code 121. A preexisting-invalid control in the same script rejects the upgrade with code 12370902. Inspect these output fields; script exit status alone does not prove the race occurred. 5. Optional timing control: On a separate disposable 9.0.2 instance at 127.0.0.1:27913 started with --setParameter enableTestCommands=1, run:    python race_determinism/failpoint_barrier_probe.py    The attached failpoint-barrier-evidence.jsonl shows the update completing while the actual upgrade scan is paused. 6. The attached race_impact_validation/evidence.jsonl records a separate clean-restart test in which the invalid document and constraint/error options persisted.
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      MongoDB Community Server 9.0.2 can return {ok: 1} for a collMod upgrade from a prepared validationLevel: "strict" / validationAction: "warn" collection to validationLevel: "constraint" / validationAction: "error" while a concurrent update makes an already-scanned document violate the validator. The final collection options are constraint/error, but one noncompliant document remains. Later invalid writes are rejected, and a separate clean-restart test shows that the inconsistent state persists.

      Expected: MongoDB documents that the constraint level guarantees every document in the collection satisfies the validator, and that the upgrade scan fails collMod when it finds a violation. A successful upgrade should preserve that invariant even when an update races with the scan.

      Actual: In three consecutive ordinary local 9.0.2 runs, collMod returned ok:1, the concurrent update succeeded, and the final collection had one invalid document under constraint/error. A separate test-only scan barrier confirmed that the update completed while the upgrade scan was paused before the final metadata change. The ordinary reproductions did not require test commands or failpoints.

      Tested environment: MongoDB Community Server 9.0.2, Windows x64 standalone, gitVersion c4d309807b94ac30edcca32e35e88a9598eadfc8, Python 3.11, PyMongo 4.18.2, synthetic localhost-only data.

      This is a product correctness report. The writer is permitted to update documents under the prior warn action; no privilege escalation or security boundary violation is claimed.

      Documentation: https://www.mongodb.com/docs/manual/core/schema-validation/specify-validation-level/
      Related issue: SERVER-134758 concerns how validate reports an already noncompliant constraint collection. This ticket concerns the concurrent update path that creates that state while collMod reports success.

            Assignee:
            Unassigned
            Reporter:
            상혁 전 (EXT)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: