I have a Rails app that runs sidekiq as a worker, like so many.
I’m about to try multi process apps for the problem that I’m describing, but I just want to be sure I understand everything correctly (IMHO there are still upsides to running individual apps for worker processes, to make them individually horizontally scalable)
My setup looks like this
- a web app
- a worker app
- a PG cluster
First I attached the web app, then the worker app to the DB cluster
flyctl pg attach -a foo --postgres-app=foo-pg
flyctl pg attach -a foo-worker --postgres-app=foo-pg --database-name=foo
The problem I have is that any job I run inside the foo-worker
app reports a PG::InsufficientPrivilege: ERROR: permission denied for table users (ActiveRecord::StatementInvalid)
error.
This makes sense, because apparently the second user has been created without any privileges:
foo=# SELECT grantee, privilege_type
FROM information_schema.role_table_grants WHERE table_name = 'users';
grantee | privilege_type
--------------------------------+----------------
foo | INSERT
foo | SELECT
foo | UPDATE
foo | DELETE
foo | TRUNCATE
foo | REFERENCES
foo | TRIGGER
(7 rows)
Note that no foo_worker
user has any privileges (though it exists). If I run the above attach command with --database-user=foo
it fails, because that user exists, and is expected to fail as per the docs.
My question above all: Is this expected behavior? Is the second attached DB user expected to have no privileges on a DB?
Of course I can flyctl pg connect
in and grant the respective privileges, but shouldn’t that be provided by the tooling?
Thanks!