Is there a way to check if an error coming from .Transact() or .ReadTransact() is retryable in golang?
I’ve found some error predicates[1], but i’m confused by the docs there, how does it return “true”?
I thought the docs imply I should compare it to err.Code, but I can’t find any 5000 error code at all[1].
The error predicate constants are for use with fdb_error_predicate in the C API. Some bindings expose APIs to use this function, but the Go bindings do not currently.
The best way to check for retryability right now is using OnError. If the error is retryable, the returned future will be set normally. If it isn’t, then the future will be set with the error that is passed in to it.
It should be noted that this function will reset your transaction and possibly inject a delay for backoff purposes.
If you wanted to see which errors are considered retryable, you can look at the implementation of fdb_error_predicate: