Prevent writes on large objects in read-only transactions - Mailing list pgsql-hackers

From Yugo NAGATA
Subject Prevent writes on large objects in read-only transactions
Date
Msg-id 20220527153028.61a4608f66abcd026fd3806f@sraoss.co.jp
Whole thread Raw
Responses Re: Prevent writes on large objects in read-only transactions
Re: Prevent writes on large objects in read-only transactions
List pgsql-hackers
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>

Attachment

pgsql-hackers by date:

Previous
From: Amit Langote
Date:
Subject: Re: doc phrase: "inheritance child"
Next
From: Kyotaro Horiguchi
Date:
Subject: Re: [BUG] Panic due to incorrect missingContrecPtr after promotion