Open
Description
Describe the bug
After writing an event to the database, we truncate the stream, then attempt to write the same event to the stream.
An exception is thrown on the second AppendToStreamAsync call.
To Reproduce
Steps to reproduce the behavior:
- Write Event to Stream1
- Delete the Stream
- Write Event to Stream1
Expected behavior
No Error should be thrown.
Actual behavior
Exception is thrown:
Grpc.Core.RpcException : Status(StatusCode="Unknown", Detail="Exception was thrown by handler.")
Config/Logs/Screenshots
If applicable, please attach your node configuration, logs or any screenshots.
EventStore details
-
EventStore server version: 22.10
-
Operating system: Windows
-
EventStore client version (if applicable): 23.0
Additional context
I have included my unit test incase it's something in the test that wrong:
[Test]
public async Task truncated_stream_can_be_written_to(){
String eventStoreConnectionString = ConfigurationReader.GetValue(Constants.KeyNameEventStoreConnectionString);
EventStoreClientSettings eventStoreClientSettings = EventStoreClientSettings.Create(eventStoreConnectionString);
eventStoreClientSettings.OperationOptions = new EventStoreClientOperationOptions(){
ThrowOnAppendFailure = false
};
EventStoreClient eventStoreClient = new(eventStoreClientSettings);
String streamName = $"TestStream{Guid.NewGuid():N}";
EventData GetEvent(){
var @event1 = new{
EventId = Guid.Parse("da3a18fe-74ae-4751-b97e-fd711fef260c"),
Id = 1,
Type = "TestEvent"
};
Byte[] bytes = Encoding.Default.GetBytes(JsonConvert.SerializeObject(@event1));
return new(Uuid.FromGuid(@event1.EventId), @event1.Type, (ReadOnlyMemory<Byte>)bytes);
}
await eventStoreClient.AppendToStreamAsync(streamName, StreamState.NoStream, new []{ GetEvent() });
//Truncate the stream
DeleteResult deleteResult = await eventStoreClient.DeleteAsync(streamName, StreamState.StreamExists);
//Get the events
EventStoreClient.ReadStreamResult result = eventStoreClient.ReadStreamAsync(Direction.Backwards, streamName, StreamPosition.Start);
ReadState readState = await result.ReadState;
readState.ShouldBe(ReadState.StreamNotFound);
IWriteResult r = await eventStoreClient.AppendToStreamAsync(streamName,
StreamState.Any,
new[] { GetEvent() },
ConfigureOperationOptions);
}