防止交易超时的方法? [英] Way to prevent transaction timeout?

查看:55
本文介绍了防止交易超时的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行耗时超过10秒的读写事务,并且它们正在超时(出现 ABORTED 错误).有没有办法指定更长的超时时间?

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?

推荐答案

无法指定事务的超时时间,但是有几种选择:

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

  1. 您可以每5-8秒定期发出一次 executeSql 请求使交易保持活力.您可以像这样进行一些琐碎的查询 SELECT 1 .有关闲置交易的更多信息,请此处.
  2. 您可以使用只读交易来代替读写事务.只读事务没有超时,并且仅在删除基础会话时才会中止.(可以手动删除会话,也可以在大约一个小时的空闲时间后自动删除会话.)
  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.

这篇关于防止交易超时的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆