You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2020/09/02 18:56:26 UTC
[couchdb-erlfdb] 01/01: Add support for reporting conflicting keys
This is an automated email from the ASF dual-hosted git repository.
davisp pushed a commit to branch report-conflicting-keys
in repository https://gitbox.apache.org/repos/asf/couchdb-erlfdb.git
commit 5c81514a6465f6a5809ac2255e3b37677be46f93
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Wed Sep 2 13:55:27 2020 -0500
Add support for reporting conflicting keys
Transactions that fail due to a conflict can be hard to debug. This
exposes a recent feature that reports keys that were in conflict if a
transaction has to be retried due to a conflict.
---
c_src/atom_names.h | 1 +
c_src/main.c | 2 ++
src/erlfdb.erl | 9 +++++++++
3 files changed, 12 insertions(+)
diff --git a/c_src/atom_names.h b/c_src/atom_names.h
index 0a6b1ad..98b5c4f 100644
--- a/c_src/atom_names.h
+++ b/c_src/atom_names.h
@@ -107,6 +107,7 @@ ATOM_MAP(allow_writes);
ATOM_MAP(disallow_writes);
ATOM_MAP(include_port_in_address);
ATOM_MAP(use_provisional_proxies);
+ATOM_MAP(report_conflicting_keys);
// Streaming mode
diff --git a/c_src/main.c b/c_src/main.c
index b693f06..0893e9f 100644
--- a/c_src/main.c
+++ b/c_src/main.c
@@ -946,6 +946,8 @@ erlfdb_transaction_set_option(
option = FDB_TR_OPTION_SIZE_LIMIT;
} else if(IS_ATOM(argv[1], use_provisional_proxies)) {
option = FDB_TR_OPTION_USE_PROVISIONAL_PROXIES;
+ } else if(IS_ATOM(argv[1], report_conflicting_keys)) {
+ option = FDB_TR_OPTION_REPORT_CONFLICTING_KEYS;
} else {
return enif_make_badarg(env);
}
diff --git a/src/erlfdb.erl b/src/erlfdb.erl
index 240925f..56ea4f7 100644
--- a/src/erlfdb.erl
+++ b/src/erlfdb.erl
@@ -115,6 +115,9 @@
% Locality
get_addresses_for_key/2,
+ % Get conflict information
+ get_conflicting_keys/1,
+
% Misc
on_error/2,
error_predicate/2,
@@ -629,6 +632,12 @@ get_addresses_for_key(?IS_SS = SS, Key) ->
get_addresses_for_key(?GET_TX(SS), Key).
+get_conflicting_keys(?IS_TX = Tx) ->
+ StartKey = <<16#FF, 16#FF, "/transaction/conflicting_keys/">>,
+ EndKey = <<16#FF, 16#FF, "/transaction/conflicting_keys/", 16#FF>>,
+ get_range(Tx, StartKey, EndKey).
+
+
on_error(?IS_TX = Tx, {erlfdb_error, ErrorCode}) ->
on_error(Tx, ErrorCode);