6.0.0
📢 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 ofOpenSession
didn't change the default behaviour but were made obsolete. We encourage using explicit session creation andLightweightSession
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 toOpenSerializableSessionAsync
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 synchronous
BuildProjectionDaemon
from theIDocumentStore
method. Use the asynchronous version instead. - Removed
Schema
fromIDocumentStore
. UseStorage
instead. - Replaced
GroupEventRange
inIAggregationRuntime
withSlicer
reference. - Removed unused
UseAppendEventForUpdateLock
setting. - Removed the
Searchable
method fromMartenRegistry
. UseIndex
instead.
By @mysticmind in #2538
- Removed synchronous
-
ASP.NET JSON streaming
WriteById
is now using correctly customonFoundStatus
. 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 addedonFoundStatus
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; nowUpdate
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
andApply
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
, andJasperFx.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
andNpgsql
, 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; nowUpdate
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 NewtonsoftJsonProperty
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
andIdentitySession
creation methods toDocumentStore
. Previously you could createDirtyTrackedSession
explicitly. Now you can create all types of sessions explicitly. We recommend using them explicitly instead of the genericOpenSession
method. By @oskardudycz in #2463
ASP.NET
- Added
onFoundStatus
to ASP.NET JSON streaming methods, so you could specify, e.g.201 Created
status for creating a new record. By @gfoidl in #2407
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
- Added support for reusing Documents in the same async projection batch . By default, Marten does batch to handle multiple events for the projection in one update. When using
EventProjection
and updating data manually usingIDocumentOperations
, this may cause changes made for previous batch items not to be visible. Now you can opt-in for tracking documents by an identity within a batch using theEnableDocumentTrackingByIdentity
async projection option. By @jeremydmiller, @oskardudycz and @Hawxy in #2510, #2527, #2472, #2473, #2517 - Enabled the possibility of applying projections with different Conjoined Tenancy scopes for projections. Enabled global projection for events with a conjoined tenancy style. By @oskardudycz in #2497, #2363
- Added console warning when async projections were registered, but no daemon was set up. By @jeremydmiller in #2511, #2509
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 usingQueueSqlCommand
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
- Fixed various issues related to breaking changes in the
System.Text.Json
v7. by @oskardudycz in #2394, JasperFx/weasel#73, #2389, #2494
- All the Critter Stack dependencies like
Weasel
,Lamar
,JasperFx.Core
,Oakton
, andJasperFx.CodeGeneration
were bumped to the latest major versions. By @jeremydmiller and @oskardudycz #2394, #2417, #2419, #2485, #2512, #2526, #2536, #2572
Schema management
- Fixed handling of
NgramSearch
whenmt_grams_vector
function is not in the public schema by @mysticmind in #2434, #2398 - Fixed database clean while using custom storage features. By @jeremydmiller in #2570, #2523
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
- Fixed
Cointains
condition for nestedHashSet
query. By @oskardudycz and @Hawxy in #2535
Projections
- Renamed aggregations into projections and
SelfAggregate
intoSnapshot
andLiveStreamAggregation
. 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
andApply
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 theGuid
id, theInvalidOperationException
will be thrown. By @jeremydmiller in #2454, #2439
Code Generation
- Ensured that setters and dynamic functions are generated for
EventProjection
by @jeremydmiller in #2455, #2438 - Made sure that code-generated files are located in the expected path by @jeremydmiller in #2467, #2405
Connection Management
- Generic
OpenSession
store options (OpenSession(SessionOptions options)
does not track changes by default. Previously, it was using identity map. Other overloads ofOpenSession
didn't change the default behaviour but were made optional. We encourage using explicit session creation andLightweightSession
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 toOpenSerializableSessionAsync
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 theSessionFactoryBase
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
- Made Patch API transformation schema changes thread-safe by @oskardudycz in #2462,
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
- Fixed flakiness in CI tests by @oskardudycz and @jeremydmiller in #2468, #2480, #2467
New Contributors
- @grzegorzorwat made their first contribution in #2391, #2470
- @joshuaflanagan made their first contribution in #2412
- @gfoidl made their first contribution in #2406, #2407, #2423, #2453
- @horego made their first contribution in #2425, #2427
- @luboshl made their first contribution in #2478
- @agross made their first contribution in #2508
- @mohsin-mehmood made their first contribution in #2549
- @Sergi0Martin made their first contribution in #2548
Full Changelog: 5.11.0...6.0.0
Milestone: https://github.com/JasperFx/marten/milestone/82?closed=1