Skip to content

hook: Use proper error codes when transactions fail

Patrick Steinhardt requested to merge pks-hook-reftx-error-code into master

When transactional voting fails in the reference-transaction hook, we'll always return an internal error code. This isn't helpful at all though, given that failure here can be expected and thus does not necessarily indicate an internal error.

This commit refactors the code to not pass GRPC error messages from the hook manager: it's a different layer, and managers shouldn't care about GRPC at all. Instead, this commit provides two new errors which get passed through to the caller such that the calling service can decide which error codes to return.

With this change, the ReferenceTransacstionHook RPC can now disambiguate errors and return one of the following three codes:

- Aborted, in case the transaction was aborted either because of
  a timeout or because of diverging nodes not reaching quorum.
  This code indicates that the client may simply retry the request
  and may now succeed.

- FailedPrecondition, in case the transaction was stopped. Stopping
  of transactions only happens in case the change wasn't allowed,
  either because of failing access checks or because of custom
  hooks. This is thus a persistent failure, retrying the transaction
  is probably not going to help.

- Internal, in case an actually unexpected error happened.

This change may eventually help us to make better sense of what's happening and also to filter out expected errors.

Merge request reports

Loading