What Is The Best Way to Handle Restart Errors in YSQL?
First and foremost, you need to be using at least version 2.12 or 2.13 of YugabyteDB along with
yb_enable_read_committed_isolation=true to use the
READ COMMITTED isolation that YSQL supports.
More specifically, it ensures clients won’t see a
Restart read required error, which is not seen in single-node PostgreSQL. However, it can occur in YugabyteDB due to the clock skew that might be present between nodes.
As per our transaction isolation documentation:
This isolation level will likely alleviate all the errors you are running into. Furthermore,
READ COMMITTED already has pessimistic locking built-in, which means a transaction might wait for another transaction to complete, which is seen in PostgreSQL. We are working on a more sophisticated implementation of pessimistic locking that will improve the performance of
READ COMMITTED in a workload with contention and also help avoid the requirement of adding a statement timeout to avoid deadlocks. Additionally, orthogonal to the work on performance-optimized pessimistic locking implementation, current limitations are set to be improved.
If you cannot upgrade your cluster, incorporate retries at the application level when these errors surface to help alleviate the issue.
For more details and examples, check out our documentation page on Read Committed Isolation Levels.
Explore our library of distributed SQL tips and tricks and general “how to” information on the YugabyteDB blog and on our DEV Community Blogs.
Check out the upcoming YugabyteDB events, including all training sessions, conferences, in-person and virtual events, and YugabyteDB Friday Tech Talks (designed for engineers by engineers).
In addition, there is some extremely popular “how to” content on the YugabyteDB YouTube channel.
Ready to start exploring YugabyteDB features? You have some great options to get started. Run the database locally on your laptop (Quick Start), deploy it to your favorite cloud provider (Multi-node Cluster Deployment), sign up for a free YugabyteDB Managed cluster, or request a full-featured trial. It’s easy! Get started today!