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

fix: reduce postgres notify messaging #409

Merged
merged 12 commits into from
Aug 26, 2024

Conversation

saikonen
Copy link
Collaborator

@saikonen saikonen commented Jan 10, 2024

Reduces Postgres notify messaging on certain tables by restricting the operations that table triggers are triggered on.

  • run/task tables: INSERT only triggers
  • metadata table: INSERT only and only for attempt/attempt_ok/code-package/code-package-url metadata entries
  • artifact table: disable triggers completely

This PR also changes the heartbeat monitoring to operate on a polling basis, instead of relying on UPDATE triggers from the database

@saikonen saikonen requested a review from romain-intel January 10, 2024 14:42
@saikonen saikonen force-pushed the fix/reduce-postgres-notify-messaging branch from 61579f9 to ce4711b Compare January 10, 2024 14:43
Copy link
Contributor

@romain-intel romain-intel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Crap -- this was just sitting as pending.

services/data/postgres_async_db.py Outdated Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got a tad confused btw -- there seems to be AsyncTaskTablePostgres here but then it is also in ui_backend_service/data/db/tables. Is this normal? Is one used for the metadata service and one for the ui backend. It was a tad confusing because then I wasn't sure which one would get to read operations/conditions, etc for triggers. It's a minor nit but just curious.

Copy link
Collaborator Author

@saikonen saikonen Jan 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the services/data table classes are functionally aimed for the original metadata services needs. During the ui_backend development introducing new stuff into them was out of scope, and if I recall correctly we did add some changes to existing methods specifically for the UI use case. This is why the ui_backend has its own table classes, that use services/data as a base

there might be some duplication nowadays as the base classes have received some changes as well, but for example keeping the custom queries that the UI relies on out of the base classes made sense back then.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but then again (to immediately contradict my points), the trigger setup has been kept in the base classes for reasons that I don't recall. Possibly due to some thoughts that the UI backend would initially run off a proper read replica so it would not be able to modify the DB to set up any triggers itself. This ended up not being possible after all due to limitations with read replicas regarding pg_notify, and eventually having the ui_backend be responsible for the trigger setup was the best option.

There is definitely a lot of room for cleanup regarding the table classes.

@saikonen saikonen marked this pull request as ready for review August 22, 2024 12:45
@saikonen saikonen force-pushed the fix/reduce-postgres-notify-messaging branch from 3daff68 to 4184f82 Compare August 23, 2024 10:42
@saikonen saikonen merged commit 85032e6 into master Aug 26, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants