xlog: rework writer API
The goal of this patch is to make the xlog writer API less confusing. It does the following changes: - Rename xlog_rename to xlog_materialize. The function strips the .inprogress suffix from an xlog file name. Usually it's called after the xlog was sealed (by writing the EOF marker) and closed but it may also be called before xlog_close in case the xlog file is going to be appended to (used in WAL). - Make xlog_sync private. It's called by xlog_close so there's no point in calling it manually. Make xlog_close fail if it fails to sync the file. - Make xlog_close flush the buffer so that the caller doesn't need to call xlog_flush manually before closing an xlog file. - Drop the reuse_fd argument of xlog_close. Instead, introduce a new function xlog_close_reuse_fd that works exactly like xlog_close except it doesn't close the fd and returns it in the out argument. - Introduce xlog_discard. It's supposed to be called on an incomplete xlog file to close its fd and unlink it. Rework all the places where we write xlog files in accordance with the new API. Note about memtx snapshot writer: use xlog_materialize and xlog_discard instead of coio_rename and coio_unlink. The new API (especially the xlog_discard helper) facilitates introduction of thorough (secure) file deletion because it significantly reduces the number of places in the code where xlog files are deleted. Needed for tarantool/tarantool-ee#540 NO_DOC=refactoring NO_TEST=refactoring NO_CHANGELOG=refactoring
Showing
- src/box/memtx_engine.cc 55 additions, 44 deletionssrc/box/memtx_engine.cc
- src/box/vy_log.c 6 additions, 19 deletionssrc/box/vy_log.c
- src/box/vy_run.c 12 additions, 17 deletionssrc/box/vy_run.c
- src/box/wal.c 19 additions, 12 deletionssrc/box/wal.c
- src/box/xlog.c 69 additions, 39 deletionssrc/box/xlog.c
- src/box/xlog.h 49 additions, 19 deletionssrc/box/xlog.h
- test/unit/xlog.c 1 addition, 1 deletiontest/unit/xlog.c
Loading
Please register or sign in to comment