Skip to content

MongoDB persistence and native transaction enlistment #233

Open

Description

@thomhurst

Implement the persistence foundation for #42 in src/Relayer.Outbox.MongoDB, its tests, benchmarks and documentation.

Scope:

  • Explicit collection/index deployment and named IOutboxStore registration.
  • Native IClientSessionHandle transaction enlistment for application writes and outgoing rows, without emulating transaction semantics.
  • Bounded UUIDv7-ordered reads, scheduling eligibility, atomic claims, fencing, renewal, completion and failure recording.
  • Preserve body, headers (including duplicate names and binary values), ordering key and original envelope identity.
  • Real replica-set Testcontainers tests for commit/abort, borrowed memory, competing claims and recovery after claim expiry.
  • Strict Native AOT publication and runtime smoke coverage without suppressing trimming or dynamic-code diagnostics; explicit serializer roots alone do not satisfy this gate. Do not mutate the driver's global configuration.
  • Document the native session call site and the fact that workers and inbox are separate work.
  • Allow an existing keyed IOutboxEnlistment to coexist with the default MongoDB enlistment. Cover independent keyed and unkeyed resolution in a registration test, following the fix for the shipped providers in Fix keyed DI guards and isolate pending request capacity #1196.

Acceptance: focused tests and build pass; appropriate per-message BenchmarkDotNet coverage; site builds. This child does not start dispatch workers or promise scheduled delivery.

The provider-independent read/claim suite and PostgreSQL adapter shipped in #245 (closing sibling #244). Reuse tests/Shared/OutboxStoreContractTests.cs from main for this child's MongoDB adapter; keep native transaction, lossless persistence and AOT coverage here.

Current external gate

Draft #242 preserves implementation; it remains blocked on strict MongoDB.Driver trimming/Native AOT support (CSHARP-4840). The recorded strict publish reproduction uses MongoDB.Driver 3.13.0; see the latest-release source check below. The shared store suite shipped in #245; reuse it rather than duplicating its extraction. No warning suppression or global serializer mutation is permitted.

Latest release check (2026-11-19): MongoDB.Driver 3.14.1 is published on NuGet. The previously reproduced strict publish failure is for 3.13.0; no 3.14.1 publish result is claimed. CSHARP-4840 remains unresolved in Backlog with no fix version. The released BsonClassMapSerializationProvider and BsonSerializationProviderBase still construct serializers using MakeGenericType/Activator without the annotations needed to resolve the recorded diagnostics. Keep on-hold until a supported native path passes strict publication and runtime smoke; a newer version number alone does not meet the gate.

Activity

  1. added
    phase-3: breadth
    area: outbox
    P3
    on Nov 2, 2026
  2. added
    in-progress
    on-hold
    on Nov 2, 2026
  3. thomhurst commented on Nov 2, 2026

    @thomhurst
    OwnerAuthor

    MongoDB.Driver 3.13.0 still fails strict .NET 10 Native AOT analysis for a BsonDocument-only native transaction, without application class maps.

    Minimal reproduction:

    1. dotnet new console --framework net10.0
    2. dotnet add package MongoDB.Driver --version 3.13.0
    3. Program.cs:
      using MongoDB.Bson;
      using MongoDB.Driver;
      using var client = new MongoClient(args[0]);
      var collection = client.GetDatabase("probe").GetCollection("outbox");
      using var session = await client.StartSessionAsync();
      session.StartTransaction();
      await collection.InsertOneAsync(session, new BsonDocument("_id", "probe"));
      await session.AbortTransactionAsync();
    4. dotnet publish -c Release -r win-x64 -p:PublishAot=true -p:IlcTreatWarningsAsErrors=true -p:TrimmerSingleWarn=false

    Expected: a supported BSON-document transaction path publishes without trimming/dynamic-code diagnostics.
    Observed: IL3050 in BsonClassMapSerializationProvider.GetSerializer and command payload serializer construction; IL2070 in BsonSerializationProviderBase.CreateSerializer; additional diagnostics from native driver/BSON internals. The same program succeeds under JIT against MongoDB 8.0.16 in a replica set. Diagnostic AOT publication without treating warnings as errors initially fails during hello with missing serializer constructor metadata; explicit constructor roots can get this narrow runtime path working but do not resolve analysis diagnostics.

    This blocks Relayer's MongoDB persistence integration from meeting its existing AOT contract. Relayer keeps its strict AOT gate unchanged.

    Implementation is preserved in draft #242 at b8482f9. The issue and PR are on hold until a supported native driver path/version passes strict Native AOT publication without suppressing diagnostics. Runtime-only constructor roots are insufficient. The draft adds a required strict CI smoke step and leaves existing warning guards intact.

    The existing upstream ticket is https://jira.mongodb.org/browse/CSHARP-4840. An attempt to attach this reproduction there was rejected with HTTP 400: "You do not have the permission to comment on this issue." GitHub issues are disabled on mongodb/mongo-csharp-driver, so the reproduction is retained here rather than filing a duplicate in the wrong repository.

  4. thomhurst commented on Nov 10, 2026

    @thomhurst
    OwnerAuthor

    Confirmed latest MongoDB.Driver release is still 3.13.0; the recorded strict native publish failure remains the gate for #242. Added that gate to the issue body; the shared store suite is already merged in #245. No implementation or AOT success is claimed.

    2026-11-13 triage: corrected the obsolete latest-3.13.0 claim. Latest release check (2026-11-13): MongoDB.Driver 3.14.0 shipped on November 12. It contains discriminator security fixes and breaking changes, so adopt that release or newer when resuming. The previously reproduced strict publish failure is for 3.13.0; no new 3.14.0 publish result is claimed. CSHARP-4840 remains unresolved with no fix version, and the released BsonClassMapSerializationProvider and BsonSerializationProviderBase retain the unannotated MakeGenericType/Activator serializer construction behind the recorded diagnostics. Keep on-hold until a supported native path passes strict publication and runtime smoke; a newer version number alone does not meet the gate.

  5. thomhurst commented on Nov 19, 2026

    @thomhurst
    OwnerAuthor

    Triage against origin/main e0b21cf: NuGet now publishes MongoDB.Driver 3.14.1. Updated the release reference; CSHARP-4840 is still unresolved with no fix version, and the released serializer sources retain the dynamic construction behind the recorded diagnostics. No new strict publication or runtime smoke result is claimed. #233/#242 remain held; #234 and #235 remain blocked by their native prerequisites. Shared contracts are already shipped, and the parent/child graph is flat.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3area: outboxin-progresson-holdphase-3: breadth

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions