LISTEN/NOTIFY on AWS Aurora/postgres
Asked Answered
C

1

10

I am hoping to implement a trigger that fires a notify on table change in PostgreSQL, but I am unable to find any definite answer to if it would work in a cluster.

Does PostgreSQL listen/notify work on AWS Aurora (both provisioned and serverless), and can I expect all clients to receive notifications regardless of what instance they are connected to?

If yes, are there any major performance concerns?

Thanks :)

Clearcole answered 3/11, 2020 at 22:31 Comment(2)
It should be quite simple to spin one up and test. Someone might have already tried.Andrej
I don't see any performance penality with aurora postgres 13.6 (serverless 2)Moreno
A
7

The best AWS Documentation implies - YES, it does work

Specifically for Aurora Serverless, there is an advisory that "LISTEN/NOTIFY" is NOT RECOMMENDED. This implies that it's possible with Aurora Serverless but not advisable. It also implies that normal RDS LISTEN/NOTIFY does work and is ok to use.

https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/aurora-serverless.html

Currently, certain SQL queries and commands, such as cursors with hold (DECLARE name ... CURSOR WITH HOLD FOR query); session-level advisory locks; temporary relations; and asynchronous notifications (LISTEN, NOTIFY commands) prevent scaling and are not recommended

My own quick test on AWS shows - Yes, it does work

  1. Launch Instance with Public Access

enter image description here

...

enter image description here

  1. Allow Traffic

enter image description here

  1. Run command in dbeaver

enter image description here

Note: This test doesn't show a successful receipt of a notification. That will need a quick console application to test that.

Andrej answered 8/12, 2020 at 4:4 Comment(2)
Note that they removed that the doc reference is for serverless 1. For serverless 2 they removed the advice : docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/…Moreno
I also have tested it on serverless 2 with postgres 13.6Moreno

© 2022 - 2024 — McMap. All rights reserved.