Re: Oom on temp (un-analyzed table caused by JIT) V16.1

Поиск
Список
Период
Сортировка
От Pavel Stehule
Тема Re: Oom on temp (un-analyzed table caused by JIT) V16.1
Дата
Msg-id CAFj8pRB4N4kr81Z74sKhbFWqik_HRqirBta5DX7sxE6rAu+2Qw@mail.gmail.com
обсуждение исходный текст
Ответ на Oom on temp (un-analyzed table caused by JIT) V16.1  (Kirk Wolak <wolakk@gmail.com>)
Список pgsql-hackers
Hi

po 15. 1. 2024 v 7:24 odesílatel Kirk Wolak <wolakk@gmail.com> napsal:
Daniel,
  You have a commit [1] that MIGHT fix this.
I have a script that recreates the problem, using random data in pg_temp.
And a nested cursor.

  It took me a few days to reduce this from actual code that was experiencing this.  If I turn off JIT, the problem goes away.  (if I don't FETCH the first row, the memory loss does not happen.  Maybe because opening a cursor is more decoration/prepare)

  I don't have an easy way to test this script right now against the commit.
I am hopeful that your fix fixes this.

  This was my first OOM issue in PG in 3yrs of working with it.

  The problem goes away if the TABLE is analyzed, or JIT is disabled.

  The current script, if run, will consume about 25% of my system memory (10GB).
Just call the function below until it dies if that's what you need.  The only way to get the memory back down is to close the connection.

SELECT pg_temp.fx(497);

Surprisingly, to me, the report from pg_get_backend_memory_contexts() doesn't really show "missing memory", which  I thought it would.  (FWIW, we caught this with multiple rounds of testing our code, slowing down, then crashing...  Is there ANY way to interrogate that we are above X% of system memory so we know to let this backend go?)

I wrote simple extension that can show memory allocation from system perspective


 

It takes about 18 minutes to run on my 4 CPU VM.

For now, we are going to add some ANALYZE statements to our code.

remember - don't run anything without VACUUM ANALYZE.

Without it, the queries can be slow - ANALYZE sets stats, VACUUM prepare visibility maps - without visibility maps index only scan cannot be used

autovacuum doesn't see into opened transactions, and autovacuum is executed in 1minute cycles. Autovacuum doesn't see temporary tables too. Temporary tables (data) are visible only from owner process.


 
We will consider disabling JIT.

Has sense only for bigger analytics queries.

Regards

Pavel
 

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

Предыдущее
От: Masahiko Sawada
Дата:
Сообщение: Re: POC PATCH: copy from ... exceptions to: (was Re: VLDB Features)
Следующее
От: Masahiko Sawada
Дата:
Сообщение: Re: Make COPY format extendable: Extract COPY TO format implementations