You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2020/04/28 18:30:54 UTC
[couchdb] branch improve-error-message-in-tx-options created (now
5fa67b1)
This is an automated email from the ASF dual-hosted git repository.
vatamane pushed a change to branch improve-error-message-in-tx-options
in repository https://gitbox.apache.org/repos/asf/couchdb.git.
at 5fa67b1 Re-enable the tx options tests
This branch includes the following new commits:
new 5fa67b1 Re-enable the tx options tests
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[couchdb] 01/01: Re-enable the tx options tests
Posted by va...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
vatamane pushed a commit to branch improve-error-message-in-tx-options
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 5fa67b1ac962e68e5fda9e47dc8a52574d397933
Author: Nick Vatamaniuc <va...@apache.org>
AuthorDate: Tue Apr 28 14:28:11 2020 -0400
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.
---
src/fabric/src/fabric2_server.erl | 16 ++++++++++++++--
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 204246a..957efff 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 2cffedc..34cb6e1 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,