-
-
Notifications
You must be signed in to change notification settings - Fork 450
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
TeardownDataOnRebuild = false prevents deleting existing projections #3213
TeardownDataOnRebuild = false prevents deleting existing projections #3213
Conversation
When commenting out this line, the test succeeds. |
Would it make sense to add I've added it locally and set the option when adding the projection and my test then succeeded. But it also broke some other tests. |
Digging into the history, I noticed that The test I ran is similar to the one in this PR but it's using At first, Commit 682c9e1 looked suspicious to my because of the refactoring, but aside from completely removing the check completely it didn't make the result worse. using System;
using System.Threading;
using System.Threading.Tasks;
using Marten.Events.Projections;
using Marten.Testing.Harness;
using Xunit;
namespace Marten.AsyncDaemon.Testing;
public class Base
{
public string Id { get; set; }
}
public class ImplementationA: Base
{
}
public class ImplementationB: Base
{
}
public class SomethingHappened
{
public Guid Id { get; set; }
}
public class ImplementationAProjection: MultiStreamAggregation<ImplementationA, string>
{
public ImplementationAProjection()
{
Identity<SomethingHappened>(e => $"a-{e.Id}");
TeardownDataOnRebuild = false;
}
public static ImplementationA Create(
SomethingHappened e
) => new() { Id = $"a-{e.Id}" };
}
public class ImplementationBProjection: MultiStreamAggregation<ImplementationB, string>
{
public ImplementationBProjection()
{
Identity<SomethingHappened>(e => $"b-{e.Id}");
TeardownDataOnRebuild = false;
}
public static ImplementationB Create(
SomethingHappened e
) => new() { Id = $"b-{e.Id}" };
}
public class MultiStreamDataTeardownOnRebuildTests: OneOffConfigurationsContext
{
[Fact]
public async Task Adheres_to_disabled_teardown_on_rebuild()
{
StoreOptions(
opts =>
{
opts.Schema.For<Base>()
.AddSubClass<ImplementationA>()
.AddSubClass<ImplementationB>();
opts.Projections.Add<ImplementationAProjection>(ProjectionLifecycle.Inline);
opts.Projections.Add<ImplementationBProjection>(ProjectionLifecycle.Inline);
}
);
var commonId = Guid.NewGuid();
using var daemon = await theStore.BuildProjectionDaemonAsync();
await using var session = theStore.LightweightSession();
session.Events.StartStream(
commonId,
new SomethingHappened() { Id = commonId }
);
await session.SaveChangesAsync();
var implementationA = await session.LoadAsync<ImplementationA>($"a-{commonId}");
var implementationB = await session.LoadAsync<ImplementationB>($"b-{commonId}");
implementationA.ShouldNotBeNull();
implementationB.ShouldNotBeNull();
await daemon.RebuildProjection<ImplementationAProjection>(CancellationToken.None);
var implementationBAfterRebuildOfA = await session.LoadAsync<ImplementationB>($"b-{commonId}");
implementationBAfterRebuildOfA.ShouldNotBeNull();
}
} |
After a few random checks in the history up to the current status, I am tempted to say that it has never worked again apart from the first commit. |
…ns doesn't teardown data on rebuild
As can be seen in the tests, the fix doesn't use the existing Having |
It's a repro for this discussion on Discord.