SFT Background Failure
Let it crash approach - stop trying to catch and propgate failure of write
This commit is contained in:
parent
eeeee07081
commit
171baefc0c
2 changed files with 27 additions and 41 deletions
|
@ -201,7 +201,6 @@
|
||||||
filename = "not set" :: string(),
|
filename = "not set" :: string(),
|
||||||
handle :: file:fd(),
|
handle :: file:fd(),
|
||||||
background_complete = false :: boolean(),
|
background_complete = false :: boolean(),
|
||||||
background_failure :: tuple(),
|
|
||||||
oversized_file = false :: boolean(),
|
oversized_file = false :: boolean(),
|
||||||
ready_for_delete = false ::boolean(),
|
ready_for_delete = false ::boolean(),
|
||||||
penciller :: pid()}).
|
penciller :: pid()}).
|
||||||
|
@ -334,16 +333,14 @@ handle_call(close, _From, State) ->
|
||||||
handle_call(clear, _From, State) ->
|
handle_call(clear, _From, State) ->
|
||||||
{stop, normal, ok, State#state{ready_for_delete=true}};
|
{stop, normal, ok, State#state{ready_for_delete=true}};
|
||||||
handle_call(background_complete, _From, State) ->
|
handle_call(background_complete, _From, State) ->
|
||||||
case State#state.background_complete of
|
if
|
||||||
true ->
|
State#state.background_complete == true ->
|
||||||
{reply,
|
{reply,
|
||||||
{ok,
|
{ok,
|
||||||
State#state.filename,
|
State#state.filename,
|
||||||
State#state.smallest_key,
|
State#state.smallest_key,
|
||||||
State#state.highest_key},
|
State#state.highest_key},
|
||||||
State};
|
State}
|
||||||
false ->
|
|
||||||
{reply, {error, State#state.background_failure}, State}
|
|
||||||
end;
|
end;
|
||||||
handle_call({set_for_delete, Penciller}, _From, State) ->
|
handle_call({set_for_delete, Penciller}, _From, State) ->
|
||||||
io:format("File ~s has been set for delete~n", [State#state.filename]),
|
io:format("File ~s has been set for delete~n", [State#state.filename]),
|
||||||
|
@ -419,25 +416,20 @@ statecheck_onreply(Reply, State) ->
|
||||||
|
|
||||||
create_levelzero(ListForFile, Filename) ->
|
create_levelzero(ListForFile, Filename) ->
|
||||||
{TmpFilename, PrmFilename} = generate_filenames(Filename),
|
{TmpFilename, PrmFilename} = generate_filenames(Filename),
|
||||||
case create_file(TmpFilename) of
|
{Handle, FileMD} = create_file(TmpFilename),
|
||||||
{error, Reason} ->
|
InputSize = length(ListForFile),
|
||||||
{error,
|
io:format("Creating file with input of size ~w~n", [InputSize]),
|
||||||
#state{background_complete=false, background_failure=Reason}};
|
Rename = {true, TmpFilename, PrmFilename},
|
||||||
{Handle, FileMD} ->
|
{ReadHandle,
|
||||||
InputSize = length(ListForFile),
|
UpdFileMD,
|
||||||
io:format("Creating file with input of size ~w~n", [InputSize]),
|
{[], []}} = complete_file(Handle, FileMD,
|
||||||
Rename = {true, TmpFilename, PrmFilename},
|
ListForFile, [],
|
||||||
{ReadHandle,
|
#level{level=0}, Rename),
|
||||||
UpdFileMD,
|
{ok,
|
||||||
{[], []}} = complete_file(Handle, FileMD,
|
UpdFileMD#state{handle=ReadHandle,
|
||||||
ListForFile, [],
|
filename=PrmFilename,
|
||||||
#level{level=0}, Rename),
|
background_complete=true,
|
||||||
{ok,
|
oversized_file=InputSize>?MAX_KEYS}}.
|
||||||
UpdFileMD#state{handle=ReadHandle,
|
|
||||||
filename=PrmFilename,
|
|
||||||
background_complete=true,
|
|
||||||
oversized_file=InputSize>?MAX_KEYS}}
|
|
||||||
end.
|
|
||||||
|
|
||||||
|
|
||||||
generate_filenames(RootFilename) ->
|
generate_filenames(RootFilename) ->
|
||||||
|
@ -461,19 +453,13 @@ generate_filenames(RootFilename) ->
|
||||||
create_file(FileName) when is_list(FileName) ->
|
create_file(FileName) when is_list(FileName) ->
|
||||||
io:format("Opening file with filename ~s~n", [FileName]),
|
io:format("Opening file with filename ~s~n", [FileName]),
|
||||||
ok = filelib:ensure_dir(FileName),
|
ok = filelib:ensure_dir(FileName),
|
||||||
case file:open(FileName, [binary, raw, read, write]) of
|
{ok, Handle} = file:open(FileName, [binary, raw, read, write]),
|
||||||
{ok, Handle} ->
|
Header = create_header(initial),
|
||||||
Header = create_header(initial),
|
{ok, _} = file:position(Handle, bof),
|
||||||
{ok, _} = file:position(Handle, bof),
|
ok = file:write(Handle, Header),
|
||||||
ok = file:write(Handle, Header),
|
{ok, StartPos} = file:position(Handle, cur),
|
||||||
{ok, StartPos} = file:position(Handle, cur),
|
FileMD = #state{next_position=StartPos, filename=FileName},
|
||||||
FileMD = #state{next_position=StartPos, filename=FileName},
|
{Handle, FileMD}.
|
||||||
{Handle, FileMD};
|
|
||||||
{error, Reason} ->
|
|
||||||
io:format("Error opening filename ~s with reason ~w",
|
|
||||||
[FileName, Reason]),
|
|
||||||
{error, Reason}
|
|
||||||
end.
|
|
||||||
|
|
||||||
|
|
||||||
create_header(initial) ->
|
create_header(initial) ->
|
||||||
|
|
|
@ -11,9 +11,9 @@
|
||||||
rotating_objects/1]).
|
rotating_objects/1]).
|
||||||
|
|
||||||
all() -> [
|
all() -> [
|
||||||
small_load_with2i %,
|
small_load_with2i,
|
||||||
% query_count,
|
query_count,
|
||||||
% rotating_objects
|
rotating_objects
|
||||||
].
|
].
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue