summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Vatamaniuc <vatamane@apache.org>2019-12-18 13:49:03 -0500
committerPaul J. Davis <paul.joseph.davis@gmail.com>2020-03-02 12:26:22 -0600
commitf358971f6ff9673af289fcdb2bbc12c09ada5d3a (patch)
treefa6e29aa1b551a43e9c8cd82dc234f6a21dbef49
parent4e8b200406baf8514a195e1b59df41bbf23bea57 (diff)
downloadcouchdb-f358971f6ff9673af289fcdb2bbc12c09ada5d3a.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,