Description
After upgrading Marten to v7.5.0 in an running system with ProjectionLifeCycle.Inline and UseOptimisiticConcurrency in v6.4.1, The system starts throwing exception and breaks.
Reproduction
My system is already running and I have projection docs on my database while using v6.4.1.
Setup code in Program.cs:
services.AddMarten(provider =>
{
var options = new StoreOptions();
options.Connection(connectionString);
options.DatabaseSchemaName = "public";
options.Events.StreamIdentity = StreamIdentity.AsString;
options.Projections
.Add<SalesOrderProjection>(ProjectionLifecycle.Inline);
options.Schema
.For<SalesOrderAggregate>()
.Identity(x => x.Id)
.UseOptimisticConcurrency(true);
return options;
}).UseLightweightSessions();
Without changing nothing in my code and just running this on the new Marten v7.5.0, I start getting this exception and the application breaks:
System.ArgumentException: An item with the same key has already been added. Key: mt_version at
System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior) at
System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value) at
System.Linq.Enumerable.ToDictionary[TSource,TKey](List`1 source, Func`2 keySelector, IEqualityComparer`1 comparer) at
Weasel.Postgresql.Tables.ItemDelta`1..ctor(IEnumerable`1 expectedItems, IEnumerable`1 actualItems, Func`3 comparison) at
Weasel.Postgresql.Tables.TableDelta.compare(Table expected, Table actual) at Weasel.Core.SchemaObjectDelta`1..ctor(T expected, T actual) at
Weasel.Postgresql.Tables.TableDelta..ctor(Table expected, Table actual) at
Weasel.Postgresql.Tables.Table.CreateDeltaAsync(DbDataReader reader, CancellationToken ct) at
Weasel.Core.SchemaMigration.DetermineAsync(DbConnection conn, CancellationToken ct, ISchemaObject[] schemaObjects) at
Weasel.Core.SchemaMigration.DetermineAsync(DbConnection conn, CancellationToken ct, ISchemaObject[] schemaObjects) at
Weasel.Core.Migrations.DatabaseBase`1.executeMigration(ISchemaObject[] schemaObjects, CancellationToken ct) at
Weasel.Core.Migrations.DatabaseBase`1.executeMigration(ISchemaObject[] schemaObjects, CancellationToken ct) at
Weasel.Core.Migrations.DatabaseBase`1.generateOrUpdateFeature(Type featureType, IFeatureSchema feature, CancellationToken token) at
Weasel.Core.Migrations.DatabaseBase`1.ensureStorageExistsAsync(IList`1 types, Type featureType, CancellationToken token) at
Marten.Events.Aggregation.AggregationRuntime`2.ApplyAsync(IDocumentOperations operations, IReadOnlyList`1 streams, CancellationToken cancellation) at
Marten.Events.EventGraph.ProcessEventsAsync(DocumentSessionBase session, CancellationToken token) at
Marten.Internal.Sessions.DocumentSessionBase.SaveChangesAsync(CancellationToken token) at
Marten.Internal.Sessions.DocumentSessionBase.SaveChangesAsync(CancellationToken token)
Current fix was just to remove the UseOptimisticConcurrency(true) and allow the migration to numeric revision to occur (alter column mt_version to integer).
Expected behavior
To be able to still use UseOptimisticConcurrency and mt_version as Guid as it still stated as an option on the docs.
Is the UseOptimisticConcurrency to be deprecated and not usable in v7.5.0 or is this a bug?
Relevant package, tooling and runtime versions
Marten 7.5.0
.NET 8
Description
After upgrading Marten to v7.5.0 in an running system with ProjectionLifeCycle.Inline and UseOptimisiticConcurrency in v6.4.1, The system starts throwing exception and breaks.
Reproduction
My system is already running and I have projection docs on my database while using v6.4.1.
Setup code in Program.cs:
Without changing nothing in my code and just running this on the new Marten v7.5.0, I start getting this exception and the application breaks:
Current fix was just to remove the UseOptimisticConcurrency(true) and allow the migration to numeric revision to occur (alter column mt_version to integer).
Expected behavior
To be able to still use UseOptimisticConcurrency and mt_version as Guid as it still stated as an option on the docs.
Is the UseOptimisticConcurrency to be deprecated and not usable in v7.5.0 or is this a bug?
Relevant package, tooling and runtime versions
Marten 7.5.0
.NET 8