Skip to content

6.0.0

Compare
Choose a tag to compare
@mysticmind mysticmind released this 03 May 14:28
· 855 commits to master since this release

馃摙 What's Breaking

  • Dropped support of .NET Core 3.1 and .NET 5 following the Official .NET Support Policy. That allowed us to benefit fully from recent .NET improvements around asynchronous code, performance etc. Plus made maintenance easier by removing branches of code. by @oskardudycz, @mohsin-mehmood in #2394, JasperFx/weasel#73, #2549

  • Upgraded Npgsql version to 7. We didn't face substantial issues this time, but see the Npgsql 7 release notes for detailed information about breaking changes. by @oskardudycz in #2394, JasperFx/weasel#73

  • Generic OpenSession store options (OpenSession(SessionOptions options) does not track changes by default. Previously, it was using identity map. Other overloads of OpenSession didn't change the default behaviour but were made obsolete. We encourage using explicit session creation and LightweightSession by default, as in the next major version, we plan to do the full switch. By @jeremydmiller.

  • Renamed asynchronous session creation to include explicit Serializable name. OpenSessionAsync was misleading, as the intention behind it was to enable proper handling of Postgres' serialized transaction level. Renamed the method to OpenSerializableSessionAsync and added explicit methods for session types. By @oskardudycz in #2514

  • Removed default projection lifecycle. We had different projection lifecycles that could depend on the projection type. That was confusing enough, and it could create nasty production issues in the case of missing that fact. We decided to make it explicit. By @oskardudycz in #2540

  • Removed obsolete methods marked as to be removed in the previous versions.:

    • Removed synchronousBuildProjectionDaemon from the IDocumentStore method. Use the asynchronous version instead.
    • Removed Schema from IDocumentStore. Use Storage instead.
    • Replaced GroupEventRange in IAggregationRuntime with Slicer reference.
    • Removed unused UseAppendEventForUpdateLock setting.
    • Removed the Searchable method from MartenRegistry. Use Index instead.

    By @mysticmind in #2538

  • ASP.NET JSON streaming WriteById is now using correctly custom onFoundStatus. We had the bug and always used the default status. It was fixed in #2407. So it's enhancement but also technically a breaking change to the behaviour. We also added onFoundStatus to other methods, so you could specify, e.g. 201 Created status for creating a new record. By @gfoidl in #2407

  • Added Optimistic concurrency checks during documents' updates. Previously, they were only handled when calling the Store method; now Update uses the same logic. by @luboshl in #2478

  • Base state passed as parameter is returned from AggregateStreamAsync instead of null when the stream is empty. AggregateStreamAsync allows passing the default state on which we're applying events. When no events were found, we were always returning null. Now we'll return the passed value. It is helpful when you filter events from a certain version or timestamp. It'll also be useful in the future for archiving scenarios. By @oskardudycz in #2543, #2541

  • Ensured events with both Create and Apply in stream aggregation were handled only once. When you defined both Create and Apply methods for the specific event, both methods were called for the single event. That wasn't expected behaviour. Now they'll be only handled once. By @elexisvenator in #2559

  • Added missing passing Cancellation Tokens in all async methods in public API. That ensures that cancellation is handled correctly across the whole codebase. Added the static analysis to ensure we won't miss them in the future. By @oskardudycz in #2488

  • All the Critter Stack dependencies like Weasel, Lamar, JasperFx.Core, Oakton, and JasperFx.CodeGeneration were bumped to the latest major versions. By @jeremydmiller and @oskardudycz #2394, #2417, #2419, #2485, #2512, #2526, #2536, #2572

馃殌 What's New

Dependencies

  • Added official support for .NET 7 with the latest versions of System.Text.Json and Npgsql, etc. by @oskardudycz in #2394

Documents

  • Added possibility to specify that document can be single tenanted (SingleTenanted option) when the global convention is to have multi-tenanted. By @oskardudycz in #2497
  • Added Optimistic concurrency checks during documents' updates. Previously, they were only handled when calling the Store method; now Update uses the same logic. by @luboshl and @jeremydmiller in #2478, #2439, #2501, #2526

Linq

  • Added dynamic OrderBy extensions for batched queries. Now you can order by multiple properties and chain the ordering together with a sort order. Added possibility to specify select statements in batch query order by (e.g. select random()). By @smbecker in #2356, #2362
  • Json serializer attributes STJ JsonPropertyName and Newtonsoft JsonProperty are now respected in Linq queries. Now, when you change the property name but use the old name thanks to the serializer attribute, Linq queries will use the name from the attribute. By @jeremydmiller in #2513, #2507

Connection Management

  • Added explicit LightweightSession and IdentitySession creation methods to DocumentStore. Previously you could create DirtyTrackedSession explicitly. Now you can create all types of sessions explicitly. We recommend using them explicitly instead of the generic OpenSession method. By @oskardudycz in #2463

ASP.NET

Projections

  • Base state passed as parameter is returned from AggregateStreamAsync instead of null when the stream is empty. AggregateStreamAsync allows passing the default state on which we're applying events. When no events when found, we were always returning null. Now we'll return the passed value. It is helpful when you filter events from a certain version or timestamp. It'll also be useful in the future for archiving scenarios. By @oskardudycz in #2543, #2541
  • Add missing ProjectAsync aggregate overload for immutable read models Now you can use records in projections that do .NET async stuff. By @Hawxy in #2520

Async Projections

Schema Management

  • Added automatic retries when schema updates are running in parallel. Marten locks the schema update using advisory locks. Previously when acquiring lock failed, then schema update also failed. Now it will be retried, which enables easier parallel automated tests and running schema migration during the startup for the containerized environment. By @oskardudycz in #2479
  • Made possible to index nullable LocalDate NodaTime type by @Leh2 in #2443

Multithread usage

  • Added missing passing Cancellation Tokens in all async methods in public API. That ensures that cancellation is handled correctly across the whole codebase. Added the static analysis to ensure we won't miss them in the future. By @oskardudycz in #2488

Docs

  • Added note to docs about parameter casting to JSONB type when using QueueSqlCommand method by @gfoidl in #2423, #2422
  • Added migration note about PLV8 being moved to a separate package and disabled by default in v4 by @joshuaflanagan in #2412
  • Enable nested sidebar in docs to break up the wall of links. Bumped also Vitepress to the latest version and removed obsolete documentation by @Hawxy in #2492
  • Added link to docs for OptimizeArtifactWorkflow in XML comments. By @Sergi0Martin in #2548
  • Added sponsors sections in docs. By @mysticmind in #2561

鉁忥笍 What's Changed

Dependencies

Schema management

Documents

  • Records load and modification are handled correctly in IdentitySession. When using an identity map, InvalidOperationException was thrown when records that had been previously loaded, modified & stored. Fixed by @Hawxy in #2473, #2471, #2516
  • Fixed the edge case in the document mapping with a custom Id name (when using the DocumentMappingExpression.Identity method to set up projection's Id field on a type which has another property with the name "Id" and an inappropriate type for Marten (other than int/long/string/Guid)) by @grzegorzorwat in #2391, #2327, #2470

Linq

Projections

  • Renamed aggregations into projections and SelfAggregate into Snapshot and LiveStreamAggregation. The established terms in the Event Sourcing community are Projection and Snapshot. Even though our naming was more precise on the implementation behind the scenes, it could be confusing. We decided to align it with the common naming and be more explicit about the intention. Old methods were marked as obsolete and will be removed in the next major release. By @oskardudycz in #2525
  • Ensured events with both Create and Apply in stream aggregation were handled only once. When you defined both Create and Apply methods for the specific event, both methods were called for the single event. That wasn't expected behaviour. Now they'll be only handled once. By @elexisvenator in #2559
  • Multi-tenanted conditional delete via projection's document operations won't fail during projection rebuild. By @jeremydmiller and @Hawxy in #2529

Async Projections

  • Async Daemon won't stop now when getting an error on leader election. If an error occurred during polling for ownership, the daemon became idle. Now the coordinator keeps polling for ownership on errors. By @Leh2 in #2449
  • Fixed handling shardTimeout during projection rebuild. Added proper passing of it to the Async Daemon call by @horego in #2425, #2426
  • Aligned and fixed behaviour during post-processing during projection rebuild between asynchronous and synchronous versions by @horego #2427, #2428
  • Projection rebuild from the command line is now correctly disposed and awaited. By @gfoidl in #2453, #2450

Exception handling

  • Fixed optimistic concurrency error transformation for the unique constraint when appending events. One of the Npgsql releases changed the tricky mapping logic of unique constraint errors, and we had to adjust our mapping. by @Leh2 and @jeremydmiller in #2409, #2467, #2459
  • Added assertion in FetchForWriting that identity type matches the selected stream identity type setting. Now, when you're using, e.g. StreamIdentity.AsString but passing the Guid id, the InvalidOperationException will be thrown. By @jeremydmiller in #2454, #2439

Code Generation

Connection Management

  • Generic OpenSession store options (OpenSession(SessionOptions options) does not track changes by default. Previously, it was using identity map. Other overloads of OpenSession didn't change the default behaviour but were made optional. We encourage using explicit session creation and LightweightSession by default, as in the next major version, we plan to do the full switch. By @jeremydmiller.
  • Renamed asynchronous session creation to include explicit Serializable name. OpenSessionAsync was misleading, as the intention behind it was to enable proper handling of Postgres' serialized transaction level. Renamed the method to OpenSerializableSessionAsync and added explicit methods for session types. By @oskardudycz in #2514
  • Aligned synchronous and asynchronous session creation with the existing transaction. Both of them now create connection and enlists transactions automatically. By @Leh2 in #2392
  • Ensured that the query session created using the ForTenant method is correctly disposed by @jeremydmiller in #2455, #2446
  • Added assertion when creating nested session using ForTenant, ensuring that tenant is stored in the same database. That will make the expected usage of conjoined tenancy as to be used within a single database more explicit. By @jeremydmiller in #2506, #2353
  • Made the IdentitySessionFactory factory derive from the SessionFactoryBase by @jeremydmiller in #2574

Serialization

  • Fixed issue for the NonPublicMembersStorage.All serializer resolution causing C# record with a single parameter to fail to deserialize. by @oskardudycz in #2416, #2460
  • Ensured that proper serializer type is used for events serialization. Previously, depending on the order of registration, there may be the case when, e.g. JSON.NET was used instead of System.Text.Json. By @jeremydmiller in #2505, #2465

Multithread usage

Docs

  • Fixed misplaced XML doc comments for ProjectionOptions by @gfoidl in #2406
  • Added note about the inlined multi-stream projections usage. In the high load, concurrent updates to those projections may cause data override. That's why we recommend using them with async lifetime. By @agross in #2508

CI/CD

New Contributors

Full Changelog: 5.11.0...6.0.0
Milestone: https://github.com/JasperFx/marten/milestone/82?closed=1