Skip to content

When transaction retries after a retriable error, caller cannot inspect the original error #52

Description

@jessestimpson

This is most apparent when setting a timeout on the database object.

Db = erlfdb:open(),
ok = erlfdb:set_option(Db, timeout, <<(10000):8/little-signed-integer-unit:8>>),
erlfdb:transactional(Db, fun(Tx) ->
    io:format("Last error: ~p~n", [erlfdb:get_last_error()]),
    erlfdb:wait(erlfdb:get(Tx, <<"bar">>)),
    erlfdb:set(Tx, <<"bar">>, <<"baz">>),
    timer:sleep(5500)
end).
Last error: undefined
Last error: 1007
** exception error: {erlfdb_error,1031}
     in function  erlfdb_nif:erlfdb_future_get/1
        called as erlfdb_nif:erlfdb_future_get(#Ref<0.2097654348.3325689858.17165>)
     in call from erlfdb:do_transaction/3 (/Users/jstimpson/dev/erlang/foundationdb-beam.erlfdb/src/erlfdb.erl, line 2104)
     in call from erlfdb:do_transaction/3 (/Users/jstimpson/dev/erlang/foundationdb-beam.erlfdb/src/erlfdb.erl, line 2107)

On commit, this transaction will internally fail with 1007 transaction_to_old and be retried. On the second attempt, it will fail with 1031 transaction_timed_out, which is not a retriable error, so that is raised to the caller.

The problem is that the caller cannot know that root cause of the failure was 1007 transaction_too_old, unless they instrument it with erlfdb:get_last_error(). Can erlfdb expose this information somehow?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions