etctserver: add failpoints walBeforeSync and walAfterSync

Signed-off-by: Benjamin Wang <wachao@vmware.com>
This commit is contained in:
Benjamin Wang 2023-02-09 07:06:46 +08:00
parent b4e3ed72e3
commit 109873dcb6
2 changed files with 5 additions and 2 deletions

2
build
View File

@ -16,7 +16,7 @@ GO_LDFLAGS="$GO_LDFLAGS -X ${REPO_PATH}/version.GitSHA=${GIT_SHA}"
toggle_failpoints() { toggle_failpoints() {
mode="$1" mode="$1"
if command -v gofail >/dev/null 2>&1; then if command -v gofail >/dev/null 2>&1; then
gofail "$mode" etcdserver/ mvcc/backend/ gofail "$mode" etcdserver/ mvcc/backend/ wal/
elif [[ "$mode" != "disable" ]]; then elif [[ "$mode" != "disable" ]]; then
echo "FAILPOINTS set but gofail not found" echo "FAILPOINTS set but gofail not found"
exit 1 exit 1

View File

@ -949,7 +949,10 @@ func (w *WAL) Save(st raftpb.HardState, ents []raftpb.Entry) error {
} }
if curOff < SegmentSizeBytes { if curOff < SegmentSizeBytes {
if mustSync { if mustSync {
return w.sync() // gofail: var walBeforeSync struct{}
err = w.sync()
// gofail: var walAfterSync struct{}
return err
} }
return nil return nil
} }