Replies: 2 comments 1 reply
-
|
@Meryovi Try setting |
Beta Was this translation helpful? Give feedback.
-
|
I created a minimal repro for this issue. You can run it with I wasn't able to make the warning appear continuously like we see in our containers. My assumption is that this happens because this setup isn't a real cluster, so there's no actual leader election. That said, the warning still appears regardless of whether #!/usr/bin/env dotnet
#:sdk Microsoft.NET.Sdk
#:property TargetFramework=net10.0
#:property LangVersion=preview
#:property Nullable=enable
#:property PublishAot=false
#:package Marten@8.26.1
#:package Testcontainers.PostgreSql@4.11.0
#:package Microsoft.Extensions.Hosting@10.0.5
#:package Microsoft.Extensions.Logging.Console@10.0.5
using DotNet.Testcontainers.Builders;
using JasperFx;
using JasperFx.Events.Daemon;
using JasperFx.Events.Projections;
using Marten;
using Marten.Events.Aggregation;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Testcontainers.PostgreSql;
var postgres = new PostgreSqlBuilder("postgres:18-alpine")
.WithDatabase("marten_db")
.WithUsername("postgres")
.WithPassword("postgres")
.WithOutputConsumer(Consume.RedirectStdoutAndStderrToConsole())
.Build();
await postgres.StartAsync();
Console.WriteLine("Postgres started");
var builder = Host.CreateApplicationBuilder(args);
builder.Logging.ClearProviders();
builder.Logging.AddSimpleConsole(options =>
{
options.SingleLine = true;
options.TimestampFormat = "HH:mm:ss.fff ";
});
builder.Logging.SetMinimumLevel(LogLevel.Warning);
builder.Services
.AddMarten(options =>
{
options.Connection(postgres.GetConnectionString());
options.AutoCreateSchemaObjects = AutoCreate.All;
options.Events.UseMonitoredAdvisoryLock = false; // Doesn't change the result.
options.Projections.Add<UserProjection>(ProjectionLifecycle.Async);
})
.AddAsyncDaemon(DaemonMode.HotCold);
using var host = builder.Build();
await host.StartAsync();
Console.WriteLine("Marten host started. Press any key to stop.");
Console.ReadKey();
await host.StopAsync();
await postgres.DisposeAsync();
public record UserRegistered(Guid UserId, string Name);
public sealed record UserView(Guid Id, string Name);
public sealed class UserProjection : SingleStreamProjection<UserView, Guid>
{
public static UserView Create(UserRegistered @event) =>
new(@event.UserId, @event.Name);
} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
We are seeing repeated PostgreSQL warnings when running Marten async daemon in HotCold mode across multiple application hosts.
Observed PostgreSQL warning:
WARNING: SET LOCAL can only be used in transaction blocksSample:
With additional Npgsql command logging enabled, the nearby statements are:
and then:
This appears to come from the Postgres advisory lock acquisition path used for daemon coordination.
Why this matters:
It produces repeated WARNING entries in PostgreSQL logs
It can create concern that a transaction boundary is broken or that something is misbehaving
In environments with centralized database log monitoring, this looks like an application problem even though behavior seems otherwise functional
Expectation:
Either this path should avoid SET LOCAL when not operating inside a transaction if possible
Or the implementation should use a transactional path if SET LOCAL is required
At minimum, it would be good to know whether this is intended behavior
Environment:
Marten 8.26.0
HotCold async daemon mode
Multiple application hosts active at the same time
PostgreSQL 18 with warning log level enabled
Beta Was this translation helpful? Give feedback.
All reactions