gRPC

gRPC 9 FAILED_PRECONDITION vs 13 INTERNAL

Both gRPC 9 (FAILED_PRECONDITION) and 13 (INTERNAL) belong to the gRPC Status Codes category. 9 indicates that the operation was rejected because the system is not in a state required for the operation's execution. For example, deleting a non-empty directory. Meanwhile, 13 means that an internal error occurred. This means that some invariant expected by the underlying system has been broken.

描述

The operation was rejected because the system is not in a state required for the operation's execution. For example, deleting a non-empty directory.

何时出现

The request is valid on its own, but the system's current state doesn't allow it — like trying to delete a non-empty directory or update a resource that has been modified concurrently.

如何修复

Bring the system into the required state before retrying. For example, empty the directory first, or re-read the resource to get the latest version before updating.

描述

An internal error occurred. This means that some invariant expected by the underlying system has been broken.

何时出现

A server-side bug, a corrupted internal state, or an unexpected failure in a dependency. This is the gRPC equivalent of HTTP 500.

如何修复

Check the server error logs and traces for the root cause. This typically indicates a bug that needs to be fixed in the server code.

主要区别

1.

gRPC 9: The operation was rejected because the system is not in a state required for the operation's execution. For example, deleting a non-empty directory.

2.

gRPC 13: An internal error occurred. This means that some invariant expected by the underlying system has been broken.

3.

You encounter 9 when the request is valid on its own, but the system's current state doesn't allow it — like trying to delete a non-empty directory or update a resource that has been modified concurrently.

4.

You encounter 13 when a server-side bug, a corrupted internal state, or an unexpected failure in a dependency. This is the gRPC equivalent of HTTP 500.

何时使用哪个

For 9 (FAILED_PRECONDITION): Bring the system into the required state before retrying. For example, empty the directory first, or re-read the resource to get the latest version before updating. For 13 (INTERNAL): Check the server error logs and traces for the root cause. This typically indicates a bug that needs to be fixed in the server code.

了解更多