Skip to content

10.0.0-alpha.3

Pre-release
Pre-release

Choose a tag to compare

@jeremydmiller jeremydmiller released this 15 Nov 21:57
· 96 commits to master since this release
2d93433

Third alpha of Weasel 10.0 for the Critter Stack .NET 11 release train. Targets net10.0 and net11.0. See the 10.0 migration guide.

All three changes are for the stores built on Weasel (Marten, Polecat, Fisher). An application that only uses the schema providers is unaffected.

Hi-Lo: a synchronous NextLong never waits on async work (#833, #834)

  • HiloSequenceBase.NextLongAsync held the gate it shared with NextLong across the await of AdvanceToNextHi, so a synchronous caller blocked a thread-pool thread on asynchronous work. That's the starvation pattern of JasperFx/marten#5969.
  • The one gate is now three locks: a short state lock, one for synchronous advances, and an awaited-only one for asynchronous advances. A synchronous caller that needs a block while an async advance is in flight reserves its own. Ids stay unique; an overlap leaves a gap.
  • ⚠️ For subclasses: AdvanceToNextHi and AdvanceToNextHiSync can now overlap each other, though never themselves. An advance must install a block or throw; one that does neither now throws InvalidOperationException. TrySetCurrentHi with a negative value no longer overwrites CurrentHi.

Batch executor: only the failing statement's operation translates its error (#832, #835)

  • Npgsql 10.0.3 never fills DbException.BatchCommand (measured, even for the first statement), so OperationBatchExecutor offered a batch error to every operation in order, and an operation matching by error code alone could claim another statement's error.
  • The failing statement is now found from where the reader was when the error surfaced. Only those operations may translate it; an error none of them translates is rethrown as itself, never offered to the rest of the batch. A driver-named BatchCommand (SqlClient) still wins.
  • New OperationBatchOptions.StatementCompletion, with Weasel.Postgresql.NpgsqlStatementCompletion.HasCompleted, tells apart a run of statements that return no rows. Without it they are asked in statement order.

Pooled bdata for per-event appends (#831, #836)

  • The Rich, Quick and QuickWithServerTimestamps descriptors gain an optional WriteEventBdata (Func<IEvent, IBufferWriter<byte>, bool>). When set, the Rich append, side-effect replay and tombstone operations write each binary payload into a pooled buffer and bind a slice of it instead of a fresh array: a ~1 KB Rich append goes from 3,936 to 2,952 bytes allocated. Null keeps today's behaviour exactly.
  • New defaulted IStorageDialect.SetBinaryParameterValue. The default copies; Npgsql can bind the slice as it is, SqlClient needs a Stream over it, and Microsoft.Data.Sqlite takes only byte[].
  • ⚠️ A store that sets it must dispose the operations after the whole unit of work, retries included, as Marten's SaveChangesAsync already does. Polecat and Fisher don't dispose operations today.
  • Checked against the published Marten 10.0.0-alpha.1, Polecat 6.0.0-alpha.2 and Fisher 2.0.0-alpha.2: their dialects load against this build.

Full Changelog: 10.0.0-alpha.2...10.0.0-alpha.3