SOFT_HEAP_LIMIT knob is a no-op because bundled SQLite is built without SQLITE_ENABLE_MEMORY_MANAGEMENT
envgap__apple__foundationdb-13240
01 / FAILURE SIGNATURE
As reported upstream
No identifying execution failure has been captured.
Not a benchmark task.
- In a clean container the reported failure did not reproduce, or the known fix did not make the project run.
02 / ENVIRONMENT RECIPE
- Base commit
53fb3e71bfa2e56e0ccde9ed014a70903343640e- Manifest
contrib/sqlite/CMakeLists.txt- Reproduce
Awaiting issue-specific recipe- Run under trace
Awaiting a meaningful runtime command
03 / ORIGINAL ISSUE TEXT
apple/foundationdb #13240 · read the original issue
At startup, `fdbserver/KeyValueStoreSQLite.actor.cpp:2184` configures SQLite's soft heap limit:
```cpp
sqlite3_soft_heap_limit64(SERVER_KNOBS->SOFT_HEAP_LIMIT); // default 300 MB
```
`contrib/sqlite/CMakeLists.txt` does not define `SQLITE_ENABLE_MEMORY_MANAGEMENT`, so `sqlite3_release_memory()` compiles to a no-op (`contrib/sqlite/sqlite3.amalgamation.c:11242-11252`):
```c
SQLITE_API int sqlite3_release_memory(int n){
#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
return sqlite3PcacheReleaseMemory(n);
#else
UNUSED_PARAMETER(n);
return 0;
#endif
}
```
The `softHeapLimitEnforcer` callback installed by `sqlite3_soft_heap_limit64()` (`sqlite3.amalgamation.c:11302`) calls only `sqlite3_release_memory()`, so the configured 300 MB threshold is never enforced.
### Questions
1. Is this intentional? There is a `// SOMEDAY: Is this a performance issue?` TODO next to the call.
2. If the soft heap limit is not enforced, what actually bounds SQLite's pcache memory in a storage server? And given that this has been the case for a long time, why have there been no community/issue reports of memory growth attributable to SQLite pcache?
3. If intentional, should the `SOFT_HEAP_LIMIT` knob be removed/deprecated?
4. If not, should `contrib/sqlite/CMakeLists.txt` add `target_compile_definitions(sqlite PRIVATE SQLITE_ENABLE_MEMORY_MANAGEMENT)`?
### Version
master @ `5140696da2df47c143ae74c0f4207b65d0d94876`04 / LABELS
Labels from the report text only; not yet run
No supported category has been assigned.
Label rules and the text that matched
[]