From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Vladimir Davydov Subject: [PATCH v2 0/4] Delete old WAL files if running out of disk space Date: Tue, 23 Oct 2018 20:26:30 +0300 Message-Id: To: kostja@tarantool.org Cc: tarantool-patches@freelists.org List-ID: If a replica permanently stops working for some reason, it will pin WAL files it would need to resume until it is deleted from the _cluster system space or the master is restarted. This happens in production when an admin drops a replica and forgets to remove it from the master, and this is quite annoying, because it may result in ENOSPC errors on the master. This patch set attempts to mitigate this problem by making the WAL thread delete old WAL files and shoot off old replicas automatically when it runs out of disk space. https://github.com/tarantool/tarantool/issues/3397 https://github.com/tarantool/tarantool/commits/dv/gh-3397-wal-auto-deletion Changes in v2: - Simplify WAL fallocate logic and move it from xlog.c (xlog_fallocate) to wal.c (wal_fallocate), because it's a business of the WAL thread. Now we simply fallocate() in 1 MB blocks. - Rework xdir_collect_garbage(): pass flags instead of bool + number of files to delete; also, introduce xdir_has_garbage() to make the code more straightforward. v1: https://www.freelists.org/post/tarantool-patches/PATCH-05-Delete-old-WAL-files-if-running-out-of-disk-space Vladimir Davydov (4): xlog: turn use_coio argument of xdir_collect_garbage to flags wal: preallocate disk space before writing rows wal: notify watchers about wal file removal wal: delete old wal files when running out of disk space CMakeLists.txt | 1 + src/box/box.cc | 9 +- src/box/gc.c | 67 +++++++++- src/box/gc.h | 31 +++++ src/box/journal.c | 1 + src/box/journal.h | 4 + src/box/memtx_engine.c | 2 +- src/box/relay.cc | 8 +- src/box/txn.c | 1 + src/box/vy_log.c | 2 +- src/box/wal.c | 152 ++++++++++++++++++---- src/box/wal.h | 35 +++-- src/box/xlog.c | 59 ++++++++- src/box/xlog.h | 60 ++++++++- src/box/xrow.h | 13 ++ src/errinj.h | 1 + src/trivia/config.h.cmake | 1 + test/box/errinj.result | 18 +-- test/replication/gc_no_space.result | 234 ++++++++++++++++++++++++++++++++++ test/replication/gc_no_space.test.lua | 103 +++++++++++++++ test/replication/suite.ini | 2 +- 21 files changed, 743 insertions(+), 61 deletions(-) create mode 100644 test/replication/gc_no_space.result create mode 100644 test/replication/gc_no_space.test.lua -- 2.11.0