diff --git a/changelogs/unreleased/gh-8733-ddl-memory-leaks.md b/changelogs/unreleased/gh-8733-ddl-memory-leaks.md new file mode 100644 index 000000000000..e95d36d690a8 --- /dev/null +++ b/changelogs/unreleased/gh-8733-ddl-memory-leaks.md @@ -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). diff --git a/src/box/memtx_space.c b/src/box/memtx_space.c index 18a3dc865e00..af9d431b236b 100644 --- a/src/box/memtx_space.c +++ b/src/box/memtx_space.c @@ -974,11 +974,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; @@ -1224,6 +1224,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) @@ -1237,9 +1240,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;