Skip to content
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

box: fix memory leaks on ER_MULTISTATEMENT_TRANSACTION in DDL #8795

Merged
merged 1 commit into from
Jun 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelogs/unreleased/gh-8733-ddl-memory-leaks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## bugfix/box

* Fixed the memory leaks caused by the multi-statement transaction errors in the
space index building and the space format checking operations (gh-8773).
12 changes: 6 additions & 6 deletions src/box/memtx_space.c
Original file line number Diff line number Diff line change
Expand Up @@ -987,11 +987,11 @@ memtx_space_check_format(struct space *space, struct tuple_format *format)
if (index_size(pk) == 0)
return 0;

struct iterator *it = index_create_iterator(pk, ITER_ALL, NULL, 0);
if (it == NULL)
if (txn_check_singlestatement(txn, "space format check") != 0)
return -1;

if (txn_check_singlestatement(txn, "space format check") != 0)
struct iterator *it = index_create_iterator(pk, ITER_ALL, NULL, 0);
if (it == NULL)
return -1;

struct memtx_engine *memtx = (struct memtx_engine *)space->engine;
Expand Down Expand Up @@ -1237,6 +1237,9 @@ memtx_space_build_index(struct space *src_space, struct index *new_index,
return -1;
}

if (txn_check_singlestatement(txn, "index build") != 0)
return -1;

/* Now deal with any kind of add index during normal operation. */
struct iterator *it = index_create_iterator(pk, ITER_ALL, NULL, 0);
if (it == NULL)
Expand All @@ -1250,9 +1253,6 @@ memtx_space_build_index(struct space *src_space, struct index *new_index,
*/
bool can_yield = pk->def->type != HASH;

if (txn_check_singlestatement(txn, "index build") != 0)
return -1;

struct memtx_engine *memtx = (struct memtx_engine *)src_space->engine;
struct memtx_ddl_state state;
struct trigger on_replace;
Expand Down