This is an automated email from the ASF dual-hosted git repository. rnewson pushed a commit to branch stop-on-write-error in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit f450c860e4961890f9d1baeff50c80106ad1dd64 Author: Robert Newson <[email protected]> AuthorDate: Fri May 22 19:39:35 2026 +0100 stop on write error --- src/couch/src/couch_file.erl | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/couch/src/couch_file.erl b/src/couch/src/couch_file.erl index 2d0920f7e..c27547267 100644 --- a/src/couch/src/couch_file.erl +++ b/src/couch/src/couch_file.erl @@ -578,12 +578,12 @@ handle_call({append_bin, Bin}, _From, #file{} = File) -> % a mixed cluster case append_bins(File, [Bin]) of {{ok, [{Pos, Len}]}, File1} -> {reply, {ok, Pos, Len}, File1}; - {Error, File1} -> {reply, Error, File1} + {Error, File1} -> {stop, Error, Error, File1} end; handle_call({append_bins, Bins}, _From, #file{} = File) -> case append_bins(File, Bins) of {{ok, Resps}, File1} -> {reply, {ok, Resps}, File1}; - {Error, File1} -> {reply, Error, File1} + {Error, File1} -> {stop, Error, Error, File1} end; handle_call({write_header, Bin, Opts}, _From, #file{} = File) -> try @@ -593,7 +593,7 @@ handle_call({write_header, Bin, Opts}, _From, #file{} = File) -> ok = header_fsync(NewFile, Opts), {reply, ok, NewFile}; {{error, Err}, NewFile} -> - {reply, {error, Err}, NewFile} + {stop, {error, Err}, {error, Err}, NewFile} end catch error:{fsync_error, Error} -> @@ -637,7 +637,7 @@ append_bins(#file{fd = Fd, eof = Pos} = File, Bins) -> {AllBlocks, Resps} = lists:unzip(BlockResps), case file:write(Fd, AllBlocks) of ok -> {{ok, Resps}, File#file{eof = FinalPos}}; - Error -> {Error, reset_eof(File)} + Error -> {Error, File} end. pread(#file{} = File, PosL) -> @@ -779,7 +779,7 @@ handle_write_header(Bin, #file{fd = Fd, eof = Pos} = File) -> FinalBin = [Padding, <<1, BinSize:32/integer>> | make_blocks(5, [Bin])], case file:write(Fd, FinalBin) of ok -> {ok, File#file{eof = Pos + iolist_size(FinalBin)}}; - {error, Error} -> {{error, Error}, reset_eof(File)} + {error, Error} -> {{error, Error}, File} end. read_multi_raw_iolists_int(#file{fd = Fd, eof = Eof} = File, PosLens) -> @@ -959,11 +959,6 @@ is_idle(#file{is_sys = false}) -> process_info(Pid) -> couch_util:process_dict_get(Pid, couch_file_fd). -%% in event of a partially successful write. -reset_eof(#file{} = File) -> - {ok, Eof} = file:position(File#file.fd, eof), - File#file{eof = Eof}. - -spec generate_checksum(binary()) -> <<_:128>>. generate_checksum(Bin) when is_binary(Bin) -> case generate_xxhash_checksums() of
