dh YB
dh YB

Reputation: 1097

Getting "Already present: Duplicate request" errors in YugabyteDB YSQL

[Question posted by a user on YugabyteDB Community Slack]

Sending a lot of concurrent requests in the YSQL layer, we're getting Already present: Duplicate request, XX000 errors. Are these safe to retry ?

Upvotes: 0

Views: 84

Answers (1)

dh YB
dh YB

Reputation: 1097

Here’s a in-progress list of the retryable cases:

  • If you get Duplicate Request in the middle of transaction, then it could be safely retried.

  • If Duplicate Request was generated by standalone statement, then it is possible that original statement was executed and applied to db. So safety depends on the query and application.

  • Catalog Version Mismatch — this is really a txn conflict but specifically with a DDL. There’s already an issue to change the error code for this: https://github.com/yugabyte/yugabyte-db/issues/8597.

  • Any error with Try Again prefix — but these might already be re-mapped/retried internally.

  • Leader not ready to serve requests. and Leader does not have a valid lease. are also retryable.

  • TimedOut requests are also retryable in some cases (e.g. for pure reads and operations in transction blocks), but not safe for single-row writes.

Generally for non-XX000 error codes the same rules apply as for vanilla Postgres. (e.g. 40001 is retryable — and we should already map YB transaction errors and read restart required errors to that error code).

For XX000 (internal error), there are a number of specific errors that should be safe to retry.

Internally we already re-map some of the errors to YSQL/PG error codes (like mentioned above) and generally we aim to do that appropriately.

The full list of internal error codes are at: https://github.com/yugabyte/yugabyte-db/blob/master/src/yb/util/status.h#L149

Upvotes: 1

Related Questions