Skip to content
Permalink
Browse files
Handle stats db conflicts
Since a timestamp is used as the document id, it's possible for e.g.
multiple nodes to attempt to insert the same document, resulting in
logged errors like the following:

[error] 2022-04-05T21:00:35.302496Z node1@127.0.0.1 emulator -------- Error in process <0.588.159> on node 'node1@127.0.0.1' with exit value:
{{nocatch,conflict},[{fabric,update_doc,3,[{file,"src/fabric.erl"},{line,332}]},{ioq_server,save_to_db,0,[{file,"src/ioq_server.erl"},{line,529}]}]}

This catches cases of `error:conflict` and logs them at info level
instead.
  • Loading branch information
jaydoane committed Apr 5, 2022
1 parent 7c6cd10 commit cc271de2869edd0be4ad05cfc637bfbd0a06f272
Showing 1 changed file with 5 additions and 2 deletions.
@@ -527,8 +527,11 @@ save_to_db() ->
]},
try
fabric:update_doc(get_stats_dbname(), Doc, [])
catch error:database_does_not_exist ->
couch_log:debug("Missing IOQ stats db: ~s", [get_stats_dbname()])
catch
error:database_does_not_exist ->
couch_log:debug("Missing IOQ stats db: ~s", [get_stats_dbname()]);
error:conflict ->
couch_log:info("~p:save_to_db conflict saving ~p", [?MODULE, Doc])
end
after Timeout ->
error_logger:error_report({?MODULE, "ets transfer failed"})

0 comments on commit cc271de

Please sign in to comment.