postgrest-docs icon indicating copy to clipboard operation
postgrest-docs copied to clipboard

Add snippet for reloading on read replicas

Open steve-chavez opened this issue 1 year ago • 0 comments

Related to https://github.com/PostgREST/postgrest/issues/2781.

I thought of adding the following to http://postgrest.org/en/stable/references/schema_cache.html#automatic-schema-cache-reloading

  IF pg_is_in_recovery()
  THEN
    PERFORM pg_terminate_backend(pid) FROM pg_stat_activity 
    WHERE application_name ilike '%postgrest%';
  ELSE
	  NOTIFY pgrst, 'reload schema';
  END IF;

But terminating the connection is not graceful for a cache reload as requests will fail once.

There might be a way forward with https://github.com/PostgREST/postgrest/issues/1766#issuecomment-1581454680, so I'll hold this snippet until that's settled.

steve-chavez avatar Jun 07 '23 22:06 steve-chavez