cockroachdb / cockroachdb/cockroach
sql: nil-out pointers in deallocated prepared statement
Open
C-enhancement
E-quick-win
O-support
P-3
T-sql-queries
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
We saw a case recently where tracing enabled on a Prisma app caused Prisma to create a new prepared statement for every issued query. As far as I can tell, this is not due to an actual memory leak. Instead, the rate of allocations simply outpaced the go GC, eventually leading to 100% CPU and OOM during high QPS periods. In the past, we've handled situations like this by nil'ing out pointers in pointer-heavy data structures before losing the reference to the structure. We should do that for prepared statement memory.
Jira issue: CRDB-63297
Contributor guide
Assessment
This issue has not been assessed yet.