diff options
author | Nick Vatamaniuc <vatamane@apache.org> | 2020-04-28 14:28:11 -0400 |
---|---|---|
committer | Nick Vatamaniuc <nickva@users.noreply.github.com> | 2020-04-28 14:35:44 -0400 |
commit | cf0b032380b0b416b500f740512f4755ea299717 (patch) | |
tree | 330cb40287681d522493788437dd746d0b17740b | |
parent | c6d3a7bdd4a43c069414f6c576f8be2e116d9474 (diff) | |
download | couchdb-cf0b032380b0b416b500f740512f4755ea299717.tar.gz |
Re-enable the tx options tests
And an extra level of error checking to erlfdb:set_option since it could fail
if we forget to update erlfdb dependency or fdb server version is too old. That
operation can fail with an error:badarg which is exactly how list_to_integer
fails and result in a confusing log message.
-rw-r--r-- | src/fabric/src/fabric2_server.erl | 16 | ||||
-rw-r--r-- | src/fabric/test/fabric2_tx_options_tests.erl | 2 |
2 files changed, 15 insertions, 3 deletions
diff --git a/src/fabric/src/fabric2_server.erl b/src/fabric/src/fabric2_server.erl index 204246ae2..957efff3b 100644 --- a/src/fabric/src/fabric2_server.erl +++ b/src/fabric/src/fabric2_server.erl @@ -201,7 +201,7 @@ apply_tx_options(Db, Cfg) -> apply_tx_option(Db, Option, Val, integer) -> try - erlfdb:set_option(Db, Option, list_to_integer(Val)) + set_option(Db, Option, list_to_integer(Val)) catch error:badarg -> Msg = "~p : Invalid integer tx option ~p = ~p", @@ -212,8 +212,20 @@ apply_tx_option(Db, Option, Val, binary) -> BinVal = list_to_binary(Val), case size(BinVal) < 16 of true -> - erlfdb:set_option(Db, Option, BinVal); + set_option(Db, Option, BinVal); false -> Msg = "~p : String tx option ~p is larger than 16 bytes", couch_log:error(Msg, [?MODULE, Option]) end. + + +set_option(Db, Option, Val) -> + try + erlfdb:set_option(Db, Option, Val) + catch + % This could happen if the option is not supported by erlfdb or + % fdbsever. + error:badarg -> + Msg = "~p : Could not set fdb tx option ~p = ~p", + couch_log:error(Msg, [?MODULE, Option, Val]) + end. diff --git a/src/fabric/test/fabric2_tx_options_tests.erl b/src/fabric/test/fabric2_tx_options_tests.erl index 2cffedc20..34cb6e180 100644 --- a/src/fabric/test/fabric2_tx_options_tests.erl +++ b/src/fabric/test/fabric2_tx_options_tests.erl @@ -20,7 +20,7 @@ -include("fabric2.hrl"). -fdb_tx_options_test_DISABLE() -> +fdb_tx_options_test_() -> { "Test setting default transaction options", setup, |