memtx: fix out of memory handling for rtree
When tarantool tries to recover rtree from a snapshot and memtx_memory value is lower than it has been when the snapshot was created, server suffers from segmentation fault. This happens because there is no out of memory error handling in rtree lib. In another words, we do not check the result of malloc operation. The execution flow in case of recovery uses different way and the secondary keys are build in batches. That way has no checks and reservations. The patch adds memtx_rtree_index_reserve implementation to make sure that any memory allocation in rtree will fail. Although this gives us no additional optimization as in case of memtx_tree, the memory reservation prevents tarantool from segmentation fault. If there is not enough memory to be reserved server will fail gently with the "Failed to allocate" error message. Closes #4619
Showing
- src/box/index.cc 7 additions, 0 deletionssrc/box/index.cc
- src/box/memtx_engine.h 12 additions, 0 deletionssrc/box/memtx_engine.h
- src/box/memtx_rtree.c 19 additions, 1 deletionsrc/box/memtx_rtree.c
- src/box/memtx_space.c 0 additions, 12 deletionssrc/box/memtx_space.c
- src/lib/core/errinj.h 1 addition, 0 deletionssrc/lib/core/errinj.h
- test/box/errinj.result 99 additions, 0 deletionstest/box/errinj.result
- test/box/errinj.test.lua 29 additions, 0 deletionstest/box/errinj.test.lua
- test/box/lua/cfg_rtree.lua 8 additions, 0 deletionstest/box/lua/cfg_rtree.lua
Loading
Please register or sign in to comment