DeleteStream in V2 and V3 are returning different stream statuses.

Hello,

We are upgrade from V2.0.1 of GES to V3.0.3.

In order to test, I tried to run following test case against event store repository.

Testcase targetting V2.0.1 version

[TestMethod]

[ExpectedException(typeof(AggregateDeletedException))]

public void ThrowOnGetDeletedAggregate()

{

var savedId = SaveTestAggregateWithoutCustomHeaders(repo, 10);

var streamName = string.Format(“testAggregate-{0}”, savedId.ToString(“N”));

connection.DeleteStream(streamName, 10);

repo.GetById(savedId);

}

``

Testcase targetting V3.0.3 version

[TestMethod]

[ExpectedException(typeof(AggregateDeletedException))]

public void ThrowOnGetDeletedAggregate()

{

var savedId = SaveTestAggregateWithoutCustomHeaders(repo, 10);

var streamName = string.Format(“testAggregate-{0}”, savedId.ToString(“N”));

connection.DeleteStreamAsync(streamName, 10).Wait();

repo.GetById(savedId);

}

``

The code snippet in the repository that throws the exception:

            currentSlice = eventStoreConnection.ReadStreamEventsForwardAsync(streamName, sliceStart, sliceCount, false).Result;

            if (currentSlice.Status == SliceReadStatus.StreamNotFound)

                throw new AggregateNotFoundException(id, typeof(TAggregate));

            if (currentSlice.Status == SliceReadStatus.StreamDeleted)

                throw new AggregateDeletedException(id, typeof(TAggregate));

``

The test case targeted for V2.0.1 passes while test case targeted for V3.0.3 fails with AggregateNoteFoundException.

Has the behaviour of deleting stream changed in V3.0.3?

It being that we don't have a type called AggregateDeletedException
nor AggregateNotFoundException are you looking at some sample app etc?

if (currentSlice.Status == SliceReadStatus.StreamNotFound)
                    throw new AggregateNotFoundException(id,
typeof(TAggregate));

                if (currentSlice.Status == SliceReadStatus.StreamDeleted)
                    throw new AggregateDeletedException(id, typeof(TAggregate));

What has changed is by default streams are soft deleted instead of
hard deleted. Of course this didn't change in 3.0.3 this change was
way back at 3.0 IIRC and was documented as are all breaking changes
(hence the 2.0.1->3.0.0 semantic versioning).

If you want the same behaviour pass Hard Delete = true on delete

Cheers,

Greg

Thanks for the quick reply Greg,

Yes the exceptions are defined by me in the application.

To clarify, once a steam is soft deleted, on trying to read the stream, which status should be expected StreamNotFound or StreamDeleted)?

StreamNotFound

as it is soft deleted Deleted if hard deleted

For some background on why it was done this way its actually pretty simple.

1) If we soft delete a stream and you want it deleted you can go delete it.
2) If you hard delete something and decide you really want it soft
deleted you can't undo the hard delete.

As such we looked and saw soft-delete as the better by default option.

Much better!! thanks again for the prompt reply.