Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respond correctly when batch appending idempotent write to deleted stream (DB-535) #4059

Merged
merged 1 commit into from
Nov 22, 2023

Conversation

timothycoleman
Copy link
Contributor

@timothycoleman timothycoleman commented Nov 16, 2023

Fixed: 'Unknown' error reported to client after successful idempotent write to deleted stream.

Before this fix the null value here resulted in a NRE when sending the proto message.

The server did correctly identify that the write was idempotent and not append any more events. The IndexWriter then returns -1 as the position of the existing event because it is deleted, and this was not being correctly represented in the batch append proto message.

#4058

…ream

Before this fix the null value here resulted in a NRE when sending the proto message
@timothycoleman timothycoleman changed the title Respond correctly when batch appending idempotent write to deleted stream Respond correctly when batch appending idempotent write to deleted stream (DB-535) Nov 16, 2023
Copy link

linear bot commented Nov 16, 2023

DB-535 Idempotent write to deleted stream throws exception when appending with batch append

Repro with dotnet client 23.1.0

#nullable disable
using System;
using System.Threading.Tasks;
using EventStore.Client;

namespace quick_start {
	class Program {
		static async Task Main(string[] args) {
			var connectionString = "esdb://admin:changeitlocalhost:2113?tlsVerifyCert=false";
			var settings = EventStoreClientSettings.Create(connectionString);
			var client = new EventStoreClient(settings);

			var id = Guid.NewGuid();
			var eventId = Uuid.NewUuid();

			var es = new[] { new EventData(eventId, "type", ReadOnlyMemory<byte>.Empty) };
			var a = await client.AppendToStreamAsync($"soft-{id}", StreamState.NoStream, es);
			var b = await client.DeleteAsync($"soft-{id}", StreamState.Any);
			var c = await client.AppendToStreamAsync($"soft-{id}", StreamState.NoStream, es); // idempotent

			Console.ReadKey();
		}
	}
}

results in

Unhandled exception. Grpc.Core.RpcException: Status(StatusCode="Unknown", Detail="Exception was thrown by handler.")
   at EventStore.Client.Interceptors.TypedExceptionInterceptor.AsyncStreamReader`1.MoveNext(CancellationToken cancellationToken) in C:\git\EventStore\EventStore-Client-Dotnet3\src\EventStore.Client\Interceptors\TypedExceptionInterceptor.cs:line 112
   at EventStore.Client.AsyncStreamReaderExtensions.ReadAllAsync[T](IAsyncStreamReader`1 reader, CancellationToken cancellationToken)+MoveNext() in C:\git\EventStore\EventStore-Client-Dotnet3\src\EventStore.Client.Common\AsyncStreamReaderExtensions.cs:line 9
   at EventStore.Client.AsyncStreamReaderExtensions.ReadAllAsync[T](IAsyncStreamReader`1 reader, CancellationToken cancellationToken)+System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult()
   at EventStore.Client.EventStoreClient.StreamAppender.Receive() in C:\git\EventStore\EventStore-Client-Dotnet3\src\EventStore.Client.Streams\EventStoreClient.Append.cs:line 242
   at EventStore.Client.EventStoreClient.StreamAppender.Receive() in C:\git\EventStore\EventStore-Client-Dotnet3\src\EventStore.Client.Streams\EventStoreClient.Append.cs:line 242
   at System.Threading.Channels.AsyncOperation`1.GetResult(Int16 token)
   at System.Threading.Channels.ChannelReader`1.ReadAllAsync(CancellationToken cancellationToken)+MoveNext()
   at System.Threading.Channels.ChannelReader`1.ReadAllAsync(CancellationToken cancellationToken)+System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult()
   at EventStore.Client.EventStoreClient.StreamAppender.Send() in C:\git\EventStore\EventStore-Client-Dotnet3\src\EventStore.Client.Streams\EventStoreClient.Append.cs:line 271
   at EventStore.Client.EventStoreClient.StreamAppender.Send() in C:\git\EventStore\EventStore-Client-Dotnet3\src\EventStore.Client.Streams\EventStoreClient.Append.cs:line 271
   at EventStore.Client.EventStoreClient.StreamAppender.AppendInternal(Options options, IEnumerable`1 events, CancellationToken cancellationToken) in C:\git\EventStore\EventStore-Client-Dotnet3\src\EventStore.Client.Streams\EventStoreClient.Append.cs:line 296
   at EventStore.Client.EventStoreClient.AppendToStreamAsync(String streamName, StreamState expectedState, IEnumerable`1 eventData, Action`1 configureOperationOptions, Nullable`1 deadline, UserCredentials userCredentials, CancellationToken cancellationToken) in C:\git\EventStore\EventStore-Client-Dotnet3\src\EventStore.Client.Streams\EventStoreClient.Append.cs:line 89
   at quick_start.Program.Main(String[] args) in C:\git\EventStore\EventStore-Client-Dotnet3\samples\quick-start\Program.cs:line 19
   at quick_start.Program.<Main>(String[] args)

C:\git\EventStore\EventStore-Client-Dotnet3\samples\quick-start\bin\Debug\net5.0\quick-start.exe (process 3304) exited with code -532462766.
Press any key to close this window . . .

@timothycoleman timothycoleman merged commit afc43e4 into master Nov 22, 2023
14 checks passed
@timothycoleman timothycoleman deleted the timothycoleman/idempotent-writes-to-deleted branch November 22, 2023 20:09
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@timothycoleman 👉 Created pull request targeting release/oss-v22.10: #4077

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@timothycoleman 👉 Created pull request targeting release/oss-v23.10: #4078

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants