Re: terminate called after throwing an instance of 'std::bad_alloc'

From: Andres Freund <andres(at)anarazel(dot)de>
To: Justin Pryzby <pryzby(at)telsasoft(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: terminate called after throwing an instance of 'std::bad_alloc'
Date: 2021-04-19 16:41:30
Message-ID: 20210419164130.byegpfrw46mzagcu@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 2021-04-17 19:13:24 -0500, Justin Pryzby wrote:
> I'm now realizing that that's RAM use for a single query, not from continuous
> leaks across multiple queries.

What's the memory usage with inlining disabled, and whats the usage
without jit?

> This is still true with the patch even if I
> #define LLVMJIT_LLVM_CONTEXT_REUSE_MAX 1
>
> PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
> 28438 postgres 20 0 3854264 2.8g 29428 R 98.7 33.2 8:56.79 postgres: telsasoft ts 192.168.122.11(53614) BIND
>
> python3 ./jitleak.py # runs telsasoft reports
> INFO: recreating LLVM context after 2 uses
> INFO: recreating LLVM context after 2 uses
> INFO: recreating LLVM context after 2 uses
> INFO: recreating LLVM context after 2 uses
> INFO: recreating LLVM context after 2 uses
> PID 27742 finished running report; est=None rows=40745; cols=34; ... duration:538
> INFO: recreating LLVM context after 81492 uses
>
> I did:
>
> - llvm_llvm_context_reuse_count = 0;
> Assert(llvm_context != NULL);
> + elog(INFO, "recreating LLVM context after %zu uses", llvm_llvm_context_reuse_count);
> + llvm_llvm_context_reuse_count = 0;
>
> Maybe we're missing this condition somehow ?
> if (llvm_jit_context_in_use_count == 0 &&

Do you utilize cursors or such?

> Also, I just hit this assertion by cancelling the query with ^C / sigint. But
> I don't have a reprodcer for it.
>
> < 2021-04-17 19:14:23.509 ADT telsasoft >PANIC: LLVMJitContext in use count not 0 at exit (is 1)

Hm, I'll try to see how that happens - if not, do you have a backtrace?

Greetings,

Andres Freund

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2021-04-19 16:46:19 Re: Commit 86dc90056 - Rework planning and execution of UPDATE and DELETE
Previous Message Mark Dilger 2021-04-19 16:37:18 Re: pg_amcheck option to install extension