summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Vatamaniuc <vatamane@apache.org>2019-12-18 13:49:03 -0500
committerNick Vatamaniuc <nickva@users.noreply.github.com>2019-12-18 14:03:24 -0500
commitab4eafab0d555881f118b2ab19678872814b5059 (patch)
tree9ce9d551f4d2bfc0a411ebfd5e008fca38f43829
parentb3899c402c0b93833c40235a473dc67e4988b8da (diff)
downloadcouchdb-ab4eafab0d555881f118b2ab19678872814b5059.tar.gz
Improve transaction name setting when tracing FDB transactions
Previously the per-request nonce value was set as the transaction name and so in the trace logs multiple transactions ended up having the same `TransactionID` which was pretty confusing. To fix the issue, append a transaction ID to the name. The ID is guaranteed to be unique for the life of the VM node.
-rw-r--r--src/fabric/src/fabric2_fdb.erl5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/fabric/src/fabric2_fdb.erl b/src/fabric/src/fabric2_fdb.erl
index 404460ed5..6abe1f6de 100644
--- a/src/fabric/src/fabric2_fdb.erl
+++ b/src/fabric/src/fabric2_fdb.erl
@@ -118,7 +118,10 @@ do_transaction(Fun, LayerPrefix) when is_function(Fun, 1) ->
erlfdb:transactional(Db, fun(Tx) ->
case get(erlfdb_trace) of
Name when is_binary(Name) ->
- erlfdb:set_option(Tx, transaction_logging_enable, Name);
+ UId = erlang:unique_integer([positive]),
+ UIdBin = integer_to_binary(UId, 36),
+ TxId = <<Name/binary, "_", UIdBin/binary>>,
+ erlfdb:set_option(Tx, transaction_logging_enable, TxId);
_ ->
ok
end,