Explore possibility of using Postgres `NOTIFY` and `LISTEN`
- Dominant language
- Python
- Stars
- 670
- Forks
- 183
- Avg merge
- 17h 7m
- Merged PRs (30d)
- 358
Description
See https://www.postgresql.org/docs/current/sql-notify.html
It can be used to asynchronously notify the table update/delete events to other database clients. This way, we could implement a "safe" signal subsystem that triggers specific actions upon database changes.
Example:https://stackoverflow.com/questions/69678732/postgresql-notify-when-specific-column-is-updated
According to the documentation, notifications are only sent and received between transactions. This property will help us to mitigate race conditions in the event processing.
The shortcoming is that read replicas cannot run `LISTEN`, so this should be used in caution not to flood the connection pool. For this reason, I think it would be safe to first try within the manager codebase only.
Another concern is to keep the stored procedures (as in the linked example) up-to-date when they are changed. We should consider using a special naming convention for them to check existence of them during alembic migrations.
Let's explore and experiment with this to improve the asynchronous database updates with callbacks upon specific row/column changes.
JIRA Issue: BA-201
Contributor guide
Assessment
This issue has not been assessed yet.