You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2021/03/24 21:54:31 UTC
[couchdb-erlfdb] branch experimental-buggify-resistance updated:
[wip] Log per-transaction retry counts along with the error
This is an automated email from the ASF dual-hosted git repository.
vatamane pushed a commit to branch experimental-buggify-resistance
in repository https://gitbox.apache.org/repos/asf/couchdb-erlfdb.git
The following commit(s) were added to refs/heads/experimental-buggify-resistance by this push:
new 7e4b30f [wip] Log per-transaction retry counts along with the error
7e4b30f is described below
commit 7e4b30fa03df12e9021d9e2581b883aa89f2abec
Author: Nick Vatamaniuc <va...@apache.org>
AuthorDate: Wed Mar 24 17:52:07 2021 -0400
[wip] Log per-transaction retry counts along with the error
---
src/erlfdb.erl | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/src/erlfdb.erl b/src/erlfdb.erl
index 4c212cd..25beb6f 100644
--- a/src/erlfdb.erl
+++ b/src/erlfdb.erl
@@ -677,21 +677,39 @@ clear_erlfdb_error() ->
do_transaction(?IS_TX = Tx, UserFun) ->
+ increment_tx_retries(Tx),
try
Ret = UserFun(Tx),
case is_read_only(Tx) andalso not has_watches(Tx) of
true -> ok;
false -> wait(commit(Tx), [{timeout, infinity}])
end,
+ clear_tx_retries(Tx),
Ret
catch error:{erlfdb_error, Code} ->
put(?ERLFDB_ERROR, Code),
- %couch_log:error(" +++ erlfdb error ~p tx:~p fun:~p", [Code, Tx, UserFun]),
+ couch_log:error(" +++++ erlfdb tx error ~p tx:~p retries:~p", [Code, Tx, get_tx_retries(Tx)]),
wait(on_error(Tx, Code), [{timeout, infinity}]),
do_transaction(Tx, UserFun)
end.
+get_tx_retries(Tx) ->
+ case erlang:get({'$erlfdb_retries', Tx}) of
+ undefined -> 0;
+ N when is_integer(N) -> N
+ end.
+
+
+increment_tx_retries(Tx) ->
+ Retries = get_tx_retries(Tx),
+ put({'$erlfdb_retries', Tx}, Retries + 1).
+
+
+clear_tx_retries(Tx) ->
+ erase({'$erlfdb_retries', Tx}).
+
+
fold_range_int(?IS_TX = Tx, StartKey, EndKey, Fun, Acc, Options) ->
St = options_to_fold_st(StartKey, EndKey, Options),
fold_range_int(Tx, St, Fun, Acc).