1

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?

2
  • Add as update to your question 1) Postgres version. 2) The actual test code that failed. The error is telling you that whatever role(user) was executing the code did not have the required permissions to do so. Feb 25, 2022 at 17:21
  • What was the query associated with that error? It should be in the database server logs.
    – jjanes
    Feb 26, 2022 at 17:23

1 Answer 1

1

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.

2
  • Looks like we weren't using a superuser; we switched this user to a superuser (it's just for local testing so no security issues) and haven't been able to reproduce this across hundreds of test runs.
    – amkingTRP
    Mar 2, 2022 at 9:06
  • 1
    Don't ever use a superuser as application user. And testing should have a setup as close to production as possible. Use the pg_signal_backend role. Mar 2, 2022 at 9:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.