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

Incoming envelopes table not found in ancillary store with custom schema #1133

Closed
manio143 opened this issue Nov 17, 2024 · 1 comment
Closed
Labels
bug Something isn't working duplicate This issue or pull request already exists

Comments

@manio143
Copy link

Describe the bug
Wolverine configured with Marten with an ancillary store seems to be polling a non-existing table wolverine_incoming_envelopes in the ancillary schema.
The events are being handled without issue but I'm getting this error in the logs every couple seconds.

According to documentation: https://wolverinefx.io/guide/durability/marten/ancillary-stores

What's not (yet) supported
Controlling which schema the Wolverine envelope tables are placed in. Today they will be placed in the default schema for the ancillary store

They way I initially understood it was that envelope queries were going to be made against the default schema (the default store), even when there are ancillary stores defined, but I think what it meant is that they are made against ancillary store schema (and not for example Events schema). That's fine, but that table is not created.

To Reproduce

builder.Services.AddMarten(options =>
{
	options.Connection(builder.Configuration.GetConnectionString("postgres") ?? string.Empty);
	options.AutoCreateSchemaObjects = AutoCreate.All;
}).IntegrateWithWolverine().UseLightweightSessions();

builder.Services.AddMartenStore<ICounterStore>(options =>
{
	options.Connection(builder.Configuration.GetConnectionString("postgres") ?? string.Empty);
	options.DatabaseSchemaName = "counters";
	options.AutoCreateSchemaObjects = AutoCreate.All;
	options.Events.StreamIdentity = Marten.Events.StreamIdentity.AsString;
}).IntegrateWithWolverine();

builder.Services.AddWolverine();
Events and Endpoints configuration (less relevant)
WebApplication app = builder.Build();
app.MapGet("/counter/{id}", async ([FromRoute] string id, ICounterStore store) =>
{
	IDocumentSession session = store.LightweightSession();
	Counter? counter = session.Events.AggregateStream<Counter>(id);
	return counter?.Value ?? 0;
});
app.MapPost("/counter/{id}/increase", async ([FromRoute] string id, IMessageBus bus) =>
{
	await bus.InvokeAsync(new IncreaseCounterCommand(id));
	return "Counter increased";
});

public interface ICounterStore : IDocumentStore;
public record IncreaseCounterCommand(string CounterId);
public record CounterIncreased(string CounterId);

public class Counter
{
	public string Id { get; set; } = default!;
	public int Value { get; set; }

	public void Apply(CounterIncreased _)
	{
		this.Value++;
	}
}

[MartenStore(typeof(ICounterStore))]
public static class IncreaseCounterCommandHandler
{
	[AggregateHandler(AggregateType = typeof(Counter))]
	public static CounterIncreased Handle(IncreaseCounterCommand command)
	{
		return new CounterIncreased(command.CounterId);
	}
}

Expected behavior
No errors.

StackTrace

Wolverine.RDBMS.Polling.DatabaseBatchCommandException: Database operation batch failure:
1. Wolverine.RDBMS.Durability.CheckRecoverableIncomingMessagesOperation
2. Wolverine.RDBMS.Durability.CheckRecoverableOutgoingMessagesOperation
3. Wolverine.RDBMS.Durability.DeleteExpiredEnvelopesOperation
4. Wolverine.RDBMS.Durability.MoveReplayableErrorMessagesToIncomingOperation
select received_at, count(*) from counters.wolverine_incoming_envelopes where status = 'Incoming' and owner_id = 0 group by received_at;select distinct destination from counters.wolverine_outgoing_envelopes where owner_id = 0;delete from counters.wolverine_incoming_envelopes where status = 'Handled' and keep_until <= @p0;insert into counters.wolverine_incoming_envelopes (body, id, status, owner_id, execution_time, attempts, message_type, received_at) select body, id, 'Incoming', 0, null, 0, message_type, received_at from counters.wolverine_dead_letters where replayable = @replayable;delete from counters.wolverine_dead_letters where replayable = @replayable;
p0: 17/11/2024 20:58:18 +00:00
replayable: True
 ---> Npgsql.PostgresException (0x80004005): 42P01: relation "counters.wolverine_incoming_envelopes" does not exist

POSITION: 35
   at Npgsql.Internal.NpgsqlConnector.ReadMessageLong(Boolean async, DataRowLoadingMode dataRowLoadingMode, Boolean readingNotifications, Boolean isReadingPrependedMessage)
   at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1.StateMachineBox`1.System.Threading.Tasks.Sources.IValueTaskSource<TResult>.GetResult(Int16 token)
   at Npgsql.NpgsqlDataReader.NextResult(Boolean async, Boolean isConsuming, CancellationToken cancellationToken)
   at Npgsql.NpgsqlDataReader.NextResult(Boolean async, Boolean isConsuming, CancellationToken cancellationToken)
   at Npgsql.NpgsqlCommand.ExecuteReader(Boolean async, CommandBehavior behavior, CancellationToken cancellationToken)
   at Npgsql.NpgsqlCommand.ExecuteReader(Boolean async, CommandBehavior behavior, CancellationToken cancellationToken)
   at Npgsql.NpgsqlCommand.ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)
   at Wolverine.RDBMS.Polling.DatabaseOperationBatch.ExecuteAsync(IWolverineRuntime runtime, CancellationToken cancellationToken) in /home/runner/work/wolverine/wolverine/src/Persistence/Wolverine.RDBMS/Polling/DatabaseOperationBatch.cs:line 68
  Exception data:
    Severity: ERROR
    SqlState: 42P01
    MessageText: relation "counters.wolverine_incoming_envelopes" does not exist
    Position: 35
    File: parse_relation.c
    Line: 1428
    Routine: parserOpenTable
   --- End of inner exception stack trace ---
   at Wolverine.RDBMS.Polling.DatabaseOperationBatch.ExecuteAsync(IWolverineRuntime runtime, CancellationToken cancellationToken) in /home/runner/work/wolverine/wolverine/src/Persistence/Wolverine.RDBMS/Polling/DatabaseOperationBatch.cs:line 78
   at Wolverine.RDBMS.Polling.DatabaseOperationBatch.ExecuteAsync(IWolverineRuntime runtime, CancellationToken cancellationToken) in /home/runner/work/wolverine/wolverine/src/Persistence/Wolverine.RDBMS/Polling/DatabaseOperationBatch.cs:line 89
   at Wolverine.Runtime.Agents.AgentCommandHandler.HandleAsync(MessageContext context, CancellationToken cancellation) in /home/runner/work/wolverine/wolverine/src/Wolverine/Runtime/Agents/AgentCommandHandler.cs:line 36
   at Wolverine.Runtime.Handlers.Executor.InvokeAsync(MessageContext context, CancellationToken cancellation) in /home/runner/work/wolverine/wolverine/src/Wolverine/Runtime/Handlers/Executor.cs:line 204
   at Wolverine.Runtime.Handlers.Executor.InvokeAsync(MessageContext context, CancellationToken cancellation)
   at Wolverine.Runtime.Handlers.Executor.InvokeInlineAsync(Envelope envelope, CancellationToken cancellation) in /home/runner/work/wolverine/wolverine/src/Wolverine/Runtime/Handlers/Executor.cs:line 94
   at Wolverine.RDBMS.DurabilityAgent.<>c__DisplayClass9_0.<<-ctor>b__0>d.MoveNext() in /home/runner/work/wolverine/wolverine/src/Persistence/Wolverine.RDBMS/DurabilityAgent.cs:line 50

Additional context
By changing the schema to only affect events, the errors are gone:

- options.DatabaseSchemaName = "counters";
+ options.Events.DatabaseSchemaName = "counters";
@jeremydmiller jeremydmiller added bug Something isn't working duplicate This issue or pull request already exists labels Nov 21, 2024
@jeremydmiller
Copy link
Member

Duplicate with #1025

Honestly, this probably doesn't get addressed until Wolverine 4.0 -- which is coming relatively soon at least

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants