gpt4 book ai didi

amazon-redshift - Redshift : serializable isolation error (1023) despite LOCK

转载 作者:行者123 更新时间:2023-12-04 07:07:06 25 4
gpt4 key购买 nike

我正在 Redshift 集群上并行运行多个批处理 ETL 操作。

我的管道执行以下操作:

在临时临时表上做一堆事情。最后,通过执行以下操作将 upsert 插入最终表(永久和跨进程共享):

BEGIN;
LOCK table X;
DELETE FROM X USING stage_table...
INSERT INTO X ...
END;

尽管如此,当我有多个并行进程时,有些会失败:

ERROR: 1023 DETAIL: Serializable isolation violation on table - 142443, transactions > forming the cycle are: 388224, 388226 (pid:32012)



(其中 142443 是我的表 X)

当我一个一个地运行这个过程时,一切都像魅力一样。我已经在其他进程上成功使用了锁(并验证它按预期工作),所以我在这里感到困惑。任何帮助表示赞赏!

最佳答案

这是预期的。如 AWS Doc 中明确所述,Redshift 使用的事务隔离级别是可序列化的

Note: READ UNCOMMITTED, READ COMMITTED, and REPEATABLE READ have no operational impact and map to SERIALIZABLE in Amazon Redshift.



具体来说,这意味着如果并行运行非 SERIALIZABLE(可以按任何顺序运行而没有结果差异)的 SQL 语句,您将得到隔离级别错误。

顺便说一下,R​​edshift 为您提供了确定哪些查询发生冲突的工具。使用您在上述日志消息中获得的数字,您可以进行如下查询:
select query, trim(querytxt) as sqlquery from stl_query where xid = 388224;

388224 形成循环的transaction_id。

关于amazon-redshift - Redshift : serializable isolation error (1023) despite LOCK,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30265058/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com