vinyl: add test on failed write iterator during compaction
vy_task_write_run() is executed in auxiliary thread (dump or compaction). Write iterator is created and used inside this function. Meanwhile, creating/destroying tuples in these threads does not change reference counter of corresponding tuple formats (see vy_tuple_delete() and vy_stmt_alloc()). Without cleaning up write iterator right in write_iterator_start() after fail, this procedure takes place in vy_task_compaction_abort() or vy_task_dump_abort(). These *_abort() functions in turn are executed in the main thread. Taking this into consideration, tuple might be allocated in aux. thread and deleted in the main thread. As a result, format reference counter might decrease, whereas it shouldn't change (otherwise tuple format will be destroyed before all tuples of this format are gone). Fortunately, clean-up of write iterator in another thread was found only on 1.10 branch, master branch already contains fix but lacks test (2f17c929). So let's introduce test with following scenario: 1. run compaction process; 2. add one or more slice sources in vy_write_iterator_start(): corresponding slice_stream structures obtain newly created tuples in vy_slice_stream_next(); 3. the next call of vy_write_iterator_add_src() fails due to OOM, invalid run file or whatever; 4. if write_iterator_start() didn't provide clean-up of sources, it would take place in vy_task_dump_abort() which would be executed in the main thread; 5. now format reference counter would be less than it was before compaction. Closes #4864
Showing
- src/box/vy_write_iterator.c 9 additions, 0 deletionssrc/box/vy_write_iterator.c
- src/lib/core/errinj.h 1 addition, 0 deletionssrc/lib/core/errinj.h
- test/box/errinj.result 1 addition, 0 deletionstest/box/errinj.result
- test/vinyl/gh-4864-stmt-alloc-fail-compact.result 69 additions, 0 deletionstest/vinyl/gh-4864-stmt-alloc-fail-compact.result
- test/vinyl/gh-4864-stmt-alloc-fail-compact.test.lua 33 additions, 0 deletionstest/vinyl/gh-4864-stmt-alloc-fail-compact.test.lua
Loading
Please register or sign in to comment