-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ADBDEV-6577: Use short-lived SPI contexts #40
Conversation
Can you list the functions that opened SPI connection before this patch and after, and which contain which? As far as I can see
|
|
Can you add this to the description? At least the |
It's just the behavior that hasn't changed! |
added |
Use short-lived SPI contexts
diskquota uses long-lived SPI contexts in most places: at the beginning it
calls the SPI_connect function, which creates an SPI context and switches to
its use, then it does a lot of work, including SPI_execute, and only at the
very end it calls the SPI_finish function, which clears the SPI context. This
usage architecture is incorrect and can lead to memory leaks while the SPI
context is alive, because the SPI_execute function, for example, allocates
memory in it for parsing a SQL query. Correct use of SPI involves opening and
closing the SPI as close as possible, so that the SPI context is as short-lived
as possible. This patch adds new wrappers for connecting and disconnecting
functions from SPI and their usage, and moves the connection to SPI into
functions closer to making requests over SPI.
It is easier to view the changes with the "Hide whitespace" option enabled.