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

SUGGESTION - api "signal handler" to reset cache - SIGUSR1 #1622

Closed
mpasquini opened this issue Oct 14, 2020 · 6 comments
Closed

SUGGESTION - api "signal handler" to reset cache - SIGUSR1 #1622

mpasquini opened this issue Oct 14, 2020 · 6 comments

Comments

@mpasquini
Copy link

It is possible to have an api call to the signal handler ?

Before reporting a bug:
If your database schema has changed while the PostgREST server is running,
send the server a SIGUSR1 signal or restart it(http://postgrest.org/en/stable/admin.html#schema-reloading)
to ensure the schema cache is not stale. This sometimes fixes apparent bugs.

From GNU:

These signals are used for various other purposes. In general, they will not affect your program unless it explicitly uses them for something.

Macro: int SIGUSR1
Macro: int SIGUSR2

The SIGUSR1 and SIGUSR2 signals are set aside for you to use any way you want. They’re useful for simple interprocess communication, if you write a signal handler for them in the program that receives the signal.
@wolfgangwalther
Copy link
Member

It is possible to have an api call to the signal handler ?

I'm not sure I undestand what you mean - but are you maybe looking for #1542 ? (not released yet)

@steve-chavez
Copy link
Member

I think @mpasquini might be referring to calling SIGUSR1 through an endpoint, like /internal/sigusr1.

It kind of reminds to #1526 in this regard.

@wolfgangwalther
Copy link
Member

wolfgangwalther commented Oct 23, 2020

Ah, ok. That could be done with something like the following already?

CREATE FUNCTION sigusr1() RETURNS void
LANGUAGE plpgsql AS $$
BEGIN
  NOTIFY pgrst;
END
$$;

And then call it via POST /rpc/sigusr1.

Of course db-channel-enabled=true needs to be set.

@wolfgangwalther
Copy link
Member

Can this be closed?

@steve-chavez
Copy link
Member

Of course db-channel-enabled=true needs to be set.

Maybe we should default db-channel-enabled to true. We disabled it because of connection poolers #1542 (comment). However dwagin told us(#1633 (comment)) that hasql-transaction still needs to be patched for poolers to work. We can put a warning about disabling db-prepared-statements and db-channel-enabled for poolers to work later on, when we're sure we work with them.

@wolfgangwalther
Copy link
Member

Yes, I agree. In general, we should have a default config that works well for "basic" cases and does not need beginners to set up that much. I'd rather have to tell advanced users that they need to adjust their settings to support connection poolers, than beginners missing out on things like prepared statements for good performance. The same goes for db-channel-enabled - it does no harm in a regular setup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants