On Wed, Jun 17, 2020 at 9:51 AM tushar <tushar.ah...@enterprisedb.com> wrote: > 1) ALTER SYSTEM > > postgres=# alter system read only; > ALTER SYSTEM > postgres=# alter system reset all; > ALTER SYSTEM > postgres=# create table t1(n int); > ERROR: cannot execute CREATE TABLE in a read-only transaction > > Initially i thought after firing 'Alter system reset all' , it will be > back to normal. > > can't we have a syntax like - "Alter system set read_only='True' ; "
No, this needs to be separate from the GUC-modification syntax, I think. It's a different kind of state change. It doesn't, and can't, just edit postgresql.auto.conf. > 2)When i connected to postgres in a single user mode , i was not able to > set the system in read only > > [edb@tushar-ldap-docker bin]$ ./postgres --single -D data postgres > > PostgreSQL stand-alone backend 14devel > backend> alter system read only; > ERROR: checkpointer is not running > > backend> Hmm, that's an interesting finding. I wonder what happens if you make the system read only, shut it down, and then restart it in single-user mode. Given what you see here, I bet you can't put it back into a read-write state from single user mode either, which seems like a problem. Either single-user mode should allow changing between R/O and R/W, or alternatively single-user mode should ignore ALTER SYSTEM READ ONLY and always allow writes anyway. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company