apache / couchdb-erlfdb

Erlang API for FoundationDB
https://www.foundationdb.org
Apache License 2.0
29 stars 20 forks source link

Add support for reporting conflicting keys #10

Closed davisp closed 4 years ago

davisp commented 4 years ago

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.

davisp commented 4 years ago

Forgot to note, this is an option that's new in the unreleased 6.3/master branch of foundationdb. To use these a dev has to set the API verson in c_src/fdb.h to 630 to enable them (and that assume's they've built a compatible version locally). These will blow up as unsupported if they're used on anything and won't cause problems if they're not used.

This is just a super useful debugging tool so there shouldn't be a risk of adding a dependency on it before 630 is officially released.

I've not bumped the CouchDB dependency version yet as there are a few more new options that we might want to add first but weren't immediately as useful as being able to report conflict keys.

nickva commented 4 years ago

Also don't forget to set -define(DEFAULT_API_VERSION, 630). in erlfdb_nif.erl otherwise the C API would accept the Tx option but at runtime the version would still be set to 620 and the get_conflicting_keys/0 function would throw a 2004 error.