postgresql/src/backend
Daniel Gustafsson 9dce22033d llvmjit: Use explicit LLVMContextRef for inlining
When performing inlining LLVM unfortunately "leaks" types (the
types survive and are usable, but a new round of inlining will
recreate new structurally equivalent types). This accumulation
will over time amount to a memory leak which for some queries
can be large enough to trigger the OOM process killer.

To avoid accumulation of types, all IR related data is stored
in an LLVMContextRef which is dropped and recreated in order
to release all types.  Dropping and recreating incurs overhead,
so it will be done only after 100 queries. This is a heuristic
which might be revisited, but until we can get the size of the
context from LLVM we are flying a bit blind.

This issue has been reported several times, there may be more
references to it in the archives on top of the threads linked
below.

Backpatching of this fix will be handled once it has matured
in master for a bit.

Reported-By: Justin Pryzby <pryzby@telsasoft.com>
Reported-By: Kurt Roeckx <kurt@roeckx.be>
Reported-By: Jaime Casanova <jcasanov@systemguards.com.ec>
Reported-By: Lauri Laanmets <pcspets@gmail.com>
Author: Andres Freund and Daniel Gustafsson
Discussion: https://postgr.es/m/7acc8678-df5f-4923-9cf6-e843131ae89d@www.fastmail.com
Discussion: https://postgr.es/m/20201218235607.GC30237@telsasoft.com
Discussion: https://postgr.es/m/CAPH-tTxLf44s3CvUUtQpkDr1D8Hxqc2NGDzGXS1ODsfiJ6WSqA@mail.gmail.com
2023-09-27 13:02:21 +02:00
..
access MergeAttributes() and related variable renaming 2023-09-26 16:08:35 +01:00
archive Redesign archive modules 2023-02-17 14:26:42 +09:00
backup Move PG_TEMP_FILE* macros to file_utils.h. 2023-09-05 17:02:06 -07:00
bootstrap Make error messages about WAL segment size more consistent 2023-08-28 15:17:04 +02:00
catalog Add some const qualifiers 2023-09-26 11:28:57 +01:00
commands MergeAttributes() and related variable renaming 2023-09-26 16:08:35 +01:00
executor Fix RLS policy usage in MERGE. 2023-08-07 09:28:47 +01:00
foreign Expand some more uses of "deleg" to "delegation" or "delegated". 2023-05-21 10:55:18 -04:00
jit llvmjit: Use explicit LLVMContextRef for inlining 2023-09-27 13:02:21 +02:00
lib Make binaryheap available to frontend code. 2023-09-18 12:18:33 -07:00
libpq Avoid potential pfree on NULL on OpenSSL errors 2023-09-22 11:18:25 +02:00
main Remove obsolete defense against strxfrm() bugs. 2023-04-20 13:20:14 +12:00
nodes Catalog not-null constraints 2023-08-25 13:31:24 +02:00
optimizer Collect dependency information for parsed CallStmts. 2023-09-25 14:42:17 -04:00
parser Track nesting depth correctly when drilling down into RECORD Vars. 2023-09-15 17:01:52 -04:00
partitioning Add missing ObjectIdGetDatum() in syscache lookup calls for Oids 2023-07-20 15:18:25 +09:00
po Translation updates 2023-08-07 12:39:30 +02:00
port Add GUC parameter "huge_pages_status" 2023-07-06 14:42:36 +09:00
postmaster Move PG_TEMP_FILE* macros to file_utils.h. 2023-09-05 17:02:06 -07:00
regex All supported systems have locale_t. 2023-07-09 11:55:18 +12:00
replication Fix the misuse of origin filter across multiple pg_logical_slot_get_changes() calls. 2023-09-27 14:32:51 +05:30
rewrite Fix RLS policy usage in MERGE. 2023-08-07 09:28:47 +01:00
snowball Fix the install rule for snowball_create.sql. 2023-05-23 11:15:57 -04:00
statistics Take pg_attribute out of VacAttrStats 2023-07-03 07:18:57 +02:00
storage doc: correct reference to pg_relation in comment 2023-09-26 17:07:14 -04:00
tcop Fix recovery conflict SIGUSR1 handling. 2023-09-07 12:39:24 +12:00
tsearch Limit to_tsvector_byid's initial array allocation to something sane. 2023-09-25 11:50:28 -04:00
utils Add some const qualifiers 2023-09-26 11:28:57 +01:00
.gitignore
common.mk Blind attempt to fix LLVM dependency in the backend 2022-09-15 10:53:48 +07:00
Makefile Add system view pg_wait_events 2023-08-20 15:35:02 +09:00
meson.build Add win32ver data to meson-built postgres.exe. 2023-06-12 07:40:38 -07:00
nls.mk Add missing gettext triggers 2023-05-10 13:51:51 +02:00