reserved_role crashes causes segfault when renaming tables
bradnicholson opened this issue · comments
Bug report
Describe the bug
If you enable supautils.reserved_roles
, any attempts to rename a table via ALTER TABLE
crash the database.
To Reproduce
- Configure Postgres with supautils and set
supautils.reserved_roles
to a reserved role. - Create a table
- Attempt to rename the table with
alter table
- postgres will crash.
For example:
Settings from postgresql.conf
# Add settings for extensions here
shared_preload_libraries = 'supautils'
supautils.reserved_memberships = 'pg_read_server_files,pg_write_server_files,pg_execute_server_program,pg_read_all_settings'
supautils.reserved_roles = 'user_a'
Users:
test=> \du
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------------------+-----------
admin | Create role, Create DB | {}
postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
user_a | | {}
Create a table and rename it:
[root@c2e4ce2e2625 supautils-1.1.0]# psql -U admin test
psql (12.7)
Type "help" for help.
test=> CREATE TABLE foo (id int);
CREATE TABLE
test=> ALTER TABLE foo RENAME TO bar;
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.
!>
Debug PG logs from the above:
2021-08-31 18:26:06.667 UTC [226] DEBUG: CommitTransaction(1) name: unnamed; blockState: STARTED; state: INPROGRESS, xid/subid/cid: 0/1/0
2021-08-31 18:26:08.901 UTC [226] DEBUG: StartTransaction(1) name: unnamed; blockState: DEFAULT; state: INPROGRESS, xid/subid/cid: 0/1/0
2021-08-31 18:26:08.909 UTC [183] LOG: server process (PID 226) was terminated by signal 11: Segmentation fault
2021-08-31 18:26:08.909 UTC [183] DETAIL: Failed process was running: ALTER TABLE foo RENAME TO bar;
2021-08-31 18:26:08.909 UTC [183] LOG: terminating any other active server processes
2021-08-31 18:26:08.910 UTC [220] WARNING: terminating connection because of crash of another server process
2021-08-31 18:26:08.910 UTC [220] DETAIL: The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
If I remove supautils.reserved_roles
from the config, the rename statement works.
Expected behavior
Renaming a table should not cause a segfault.
System information
- OS: UBI 8
- Version of supabase: 1.1.0
- Version of Postgres 12.7 (hits other versions though)