Prevent writes on large objects in read-only transactions
Yugo Nagata <nagata@sraoss.co.jp>
From: Yugo NAGATA <nagata@sraoss.co.jp>
To: pgsql-hackers@postgresql.org
Date: 2022-05-27T06:30:28Z
Lists: pgsql-hackers
Attachments
- prevent_lo_writes_in_readonly.patch (text/x-diff) patch
Hello, Currently, lo_creat(e), lo_import, lo_unlink, lowrite, lo_put, and lo_from_bytea are allowed even in read-only transactions. By using them, pg_largeobject and pg_largeobject_metatable can be modified in read-only transactions and the effect remains after the transaction finished. Is it unacceptable behaviours, isn't it? Also, when such transactions are used in recovery mode, it fails but the messages output are not user friendly, like: postgres=# select lo_creat(42); ERROR: cannot assign OIDs during recovery postgres=# select lo_create(42); ERROR: cannot assign TransactionIds during recovery postgres=# select lo_unlink(16389); ERROR: cannot acquire lock mode AccessExclusiveLock on database objects while recovery is in progress HINT: Only RowExclusiveLock or less can be acquired on database objects during recovery. So, I would like propose to explicitly prevent such writes operations on large object in read-only transactions, like: postgres=# SELECT lo_create(42); ERROR: cannot execute lo_create in a read-only transaction The patch is attached. Regards, Yugo Nagata -- Yugo NAGATA <nagata@sraoss.co.jp>
Commits
-
Prevent write operations on large objects in read-only transactions
- 55f4802785f6 16.0 landed
-
Fix comment in regression tests for large objects
- 664da2a389e5 15.0 landed