Skip to content

Marten 9.50.3

Choose a tag to compare

@jeremydmiller jeremydmiller released this 15 Oct 19:47
8285a14

The Native AOT and hard-delete release. One new feature on the event store, two schema-naming fixes that could not be worked around, and three behaviour changes — read those before upgrading.

Note on these notes. They were rewritten after publication. 9.50.3 was cut as the JasperFx 2.90.1 dependency bump, but five pull requests had merged in the minutes before the tag, so the tag carried all of them too. The original notes described only the dependency bump and said no code change was needed. Everything below is what 9.50.3 actually contains; nothing about the published packages changed.

New

  • TombstoneStream — a hard stream delete (#5673, #5674). session.Events.TombstoneStream(id) queues a single-statement delete of a stream's tag rows, its events and its stream row — plus the mt_streams_identity row under strict identity enforcement — scoped to the session tenant under conjoined tenancy. The event sequence is never touched, and projected documents are deliberately left alone. Queued until SaveChangesAsync, like every other write.

    It is on the shared IEventStoreOperations contract as a default member that throws NotSupportedException, so a store without a hard delete stays source-compatible, and the shared StreamTombstoningCompliance suite now runs against Marten.

  • DCB tag types can be registered for Native AOT (#5649, #5674, #5676). RegisterTagType<TTag>() discovers the tag's inner type by reflecting over its members and closes a generic registration at runtime, neither of which a native image can do — so a store with a DCB tag type could not even be configured under AOT.

    opts.Events.RegisterTagType<StudentId, Guid>(x => x.Value, "student")
        .ForAggregate<StudentCourseEnrollment>();

    Naming the inner type closes the generic at compile time and the unwrapper replaces the reflection. The suffix is optional and defaults to the tag type's own name, so for a tag the inferring overload could register, this one registers the same inner type and the same table. It works identically under a JIT.

    The inferring overloads are now annotated [RequiresUnreferencedCode]/[RequiresDynamicCode], and — because an analyzer warning only reaches an application that is itself AOT-analyzed, while a store configured from inside a library gets nothing — a failure at runtime now throws naming the exact line to write, keeping the original exception as its inner exception. Automatic tag registration from projection identities logs a warning naming the same line, including the projection's ForAggregate<T>().

    With explicit registrations, tagging, tag rules, EventTagQuery, EventsExistAsync, AggregateByTagsAsync and FetchForWritingByTags into a [BoundaryAggregate] all run from a native binary. A CI job publishes and runs them.

Fixed

  • A custom foreign key name is no longer discarded under conjoined tenancy (#5672, #5678). Moving tenant_id to the front of a document foreign key regenerated the key's name unconditionally, so a name set through the foreignKeyConfiguration callback was thrown away. That is what made the identifier-length failure unfixable: the exception tells you to override the database object name, and overriding it had no effect. A generated name is still regenerated; a chosen one survives, as does the name of a ForeignKey added by hand.

  • Archiving a tagged stream no longer fails with a foreign key violation (#5675, #5679). With UseArchivedStreamPartitioning on and any DCB tag type registered, ArchiveStream came back as 23503. Each mt_event_tag_* table is partitioned by is_archived and carries a composite foreign key to mt_events; mt_archive_stream moved the events between partitions without moving the tag rows that referenced them. It now moves them, in the order that keeps both sides of a non-deferrable key consistent at every statement.

  • AllObjects() no longer applies the Hi-Lo DDL (#5665, #5670). Describing the schema provisioned part of it. The describing seam is now separate from the applying one, and is proven offline against an unreachable host.

  • A failed Rebuild-mode run can be restarted and finished from its committed progress (#5668, #5669).

Performance

  • A commit that only starts streams no longer queries for a snapshot that cannot exist (#5671, thanks @lahma). An inline single-stream projection asks storage only for the ids of streams being appended to, so a start-only commit passed an empty id array — and still paid a round trip on id = ANY($1) that could only return no rows, plus a second connection with the default UseIdentityMapForAggregates = false. The same guard removes a wasted round trip from an async daemon batch whose slices all hit the aggregate write cache.

Behaviour changes

  1. An empty DCB tag table suffix is refused. RegisterTagType<T>("") used to be accepted and named mt_event_tag_ — a real table that every tag type registered that way would share. Pass a suffix, or null for the tag type's own name.

  2. A tag type that cannot be read now throws InvalidOperationException, with the original InvalidValueTypeException as its inner exception, and a message naming the explicit registration. This happens whether or not dynamic code is available, because the same exception means "not a single-value wrapper" under a JIT and "the members were trimmed away" in a trimmed image, and nothing at runtime tells those apart.

  3. Document foreign key and index names longer than 63 characters are shortened with a deterministic hash suffix, the same treatment the document table's primary key already got. If you raised PostgreSQL's NAMEDATALEN and have a foreign key or index whose generated name is between 64 characters and your own limit, that object will be renamed and you will see it in a migration diff.

Known, not fixed

DCB tag queries return archived events, where every other event query excludes them by default — #5677. It matters most for EventsExistAsync, which is what a consistency boundary assertion is built on: an archived stream still answers yes. Independent of storage mode and of archived-stream partitioning.

Dependencies

JasperFx and JasperFx.Events move to 2.90.1, from 2.87.1 in 9.50.2. Weasel is unchanged at 9.45.0. What the JasperFx range brings:

  • 2.90.1 (#5680, #1020) — the async daemon's choice between retrying an exception thrown by projection code and dead-lettering the event now also consults TransientFailures. Marten keeps its own NpgsqlException / MartenCommandException registrations.
  • 2.90.0 — TagTypeRegistration.FromUnwrapper (#1012), and TombstoneStream on the shared contract with its StreamTombstoningCompliance suite (#1017).
  • 2.89.0 — ShardFailure.IsTransient (#1016).
  • 2.88.0 (#5669, #1015) — the Rebuild-mode resume above.