Commit 90393bf
authored
Fix memory leak: ExecutionEngine recreated per query appending to global function registry (#5222)
* Fix memory leak: ExecutionEngine recreated per query appending to global function registry
The OpenSearchExecutionEngine was not scoped as @singleton in the Guice
module, causing a new instance to be created for every SQL/PPL request
via injector.getInstance(SQLService.class). Each construction called
registerOpenSearchFunctions(), which appended entries to the static
PPLFuncImpTable.INSTANCE.externalFunctionRegistry via compute(). After
N queries, the GEOIP function list contained N entries (each holding
GeoIpFunction, SqlIdentifier, CalciteFuncSignature, PPLTypeChecker,
etc.), leading to ~2GB heap retention after ~730K queries.
Fix:
1. Add @singleton to the ExecutionEngine provider in OpenSearchPluginModule
so only one instance is created per Guice injector.
2. Change registerExternalOperator() from compute()/append to put()/replace
so repeated registrations overwrite instead of accumulating.
Signed-off-by: Kai Huang <kaihuang@amazon.com>
Signed-off-by: Kai Huang <ahkcs@amazon.com>
* Apply spotless formatting
Signed-off-by: Kai Huang <kaihuang@amazon.com>
Signed-off-by: Kai Huang <ahkcs@amazon.com>
---------
Signed-off-by: Kai Huang <kaihuang@amazon.com>
Signed-off-by: Kai Huang <ahkcs@amazon.com>1 parent df8f259 commit 90393bf
File tree
2 files changed
+4
-7
lines changed- core/src/main/java/org/opensearch/sql/expression/function
- plugin/src/main/java/org/opensearch/sql/plugin/config
2 files changed
+4
-7
lines changedLines changed: 3 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
423 | 423 | | |
424 | 424 | | |
425 | 425 | | |
426 | | - | |
| 426 | + | |
427 | 427 | | |
428 | | - | |
429 | | - | |
430 | | - | |
431 | | - | |
432 | | - | |
433 | | - | |
| 428 | + | |
| 429 | + | |
434 | 430 | | |
435 | 431 | | |
436 | 432 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
| |||
0 commit comments