sequence cache is kept forever

Поиск
Список
Период
Сортировка
От Tomas Vondra
Тема sequence cache is kept forever
Дата
Msg-id 8ac85deb-dec1-f0d8-abe0-d0d348471e8f@enterprisedb.com
обсуждение исходный текст
Ответы Re: sequence cache is kept forever  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Hi,

While working on a patch, I noticed that we never clean the cache of 
sequence values, i.e. seqhashtab in sequence.c. That is, once we create 
an entry for a sequence (by calling nextval), it will stay forever 
(until the backend terminates). Even if the sequence gets dropped, the 
entry stays behind.

The SeqTableData entries are fairly small (~30B), but even considering 
that it's still a memory leak. Not an issue for common workloads, which 
use just a handful of sequences, but sometimes people create a lot of 
temporary objects, including sequences.

Or what happens when a connection calls nextval() on a sequence, the 
sequence gets dropped, the Oid gets reused for new sequence, and then we 
call nextval() again? Seems like it might cause various issues with 
returning bogus values from stale cache.

Admittedly, it doesn't seem like a critical issue - it's been like this 
since 2002 (a2597ef179) [1] which separated the sequence cache from 
relcache, to address issues with locking.


[1] 
https://www.postgresql.org/message-id/flat/23899.1022076750%40sss.pgh.pa.us


regards

-- 
Tomas Vondra
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



В списке pgsql-hackers по дате отправления:

Предыдущее
От: wenjing
Дата:
Сообщение: Re: [Proposal] Global temporary tables
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: update with no changes