Home > Software engineering >  Would could cause a Postgres exception: 42501: must be a member of the role whose process is being t
Would could cause a Postgres exception: 42501: must be a member of the role whose process is being t

Time:03-02

I've been running component tests in a .NET 5 application using LightBDD. In each test we bring up an instance of an ASP .NET core "application" that we connect to via grpc. At the end of each test we shut down the "application".
This "application" starts a connection to a Postgres instance (in the tests this is constantly running locally in Docker and is not restarted between tests) and then closes it at shutdown.
In a sequential run of 30 tests I got the following error twice (separated by about 5 successful tests):
Postgres exception: 42501: must be a member of the role whose process is being terminated or member of pg_signal_backend

I haven't been able to reproduce it since. Does anyone know what potentially could have caused this intermittant issue?

CodePudding user response:

You get that error if you are trying to cancel a transaction of a different database session or terminate such a session, but that other session is with a different database user.

The error message informs you what privileges you need to do that: you either have to be the same user (or a member thereof), or a member of pg_signal_backend or a superuser.

  • Related