Way to prevent transaction timeout?

谁说胖子不能爱 提交于 2019-12-11 06:06:10

问题


I'm running read-write transactions that are taking longer than 10 seconds, and they are timing out (failing with ABORTED errors). Is there a way to specify a longer timeout?


回答1:


There is no way to specify the timeout for a transaction, but you have a few options:

  1. You could periodically issue an executeSql request every 5-8 seconds to keep your transaction alive. You can do a trivial query like SELECT 1. More info on idle transactions is here.
  2. You could use a read-only transaction instead of a read-write transaction. Read-only transactions do not have a timeout, and they are only aborted if the underlying session is deleted. (Sessions can be deleted manually, or automatically after approximately an hour of idle time.)

You should consider whether you really need such a long read-write transaction. Read-write transactions use locks and other resources that can block other transactions from making progress. This is usually an anti-pattern to have such long-lived read-write transactions.



来源:https://stackoverflow.com/questions/44312793/way-to-prevent-transaction-timeout

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!