Hi hackers! While working on Pluggable TOAST we've detected a defective behavior on tables with large amounts of TOASTed data - queries freeze and DB stalls. Further investigation led us to the loop with GetNewOidWithIndex function call - when all available Oid already exist in the related TOAST table this loop continues infinitely. Data type used for value ID is the UINT32, which is unsigned int and has a maximum value of *4294967295* which allows maximum 4294967295 records in the TOAST table. It is not a very big amount for modern databases and is the major problem for productive systems.
Quick fix for this problem is limiting GetNewOidWithIndex loops to some reasonable amount defined by related macro and returning error if there is still no available Oid. Please check attached patch, any feedback is appreciated. -- Regards, Nikita Malakhov Postgres Professional https://postgrespro.ru/
0001_infinite_new_toast_oid_v1.patch
Description: Binary data