DBT模型挂

问题描述

我使用macOS,但在大桌子上无法完全刷新。在运行期间,它似乎挂起,并且在redshift中没有运行查询。对于较小的表,这不会发生,如果运行增量表,也不会发生。该表过去较小,只要指定了表,我就可以运行完全刷新。现在更大了,我似乎遇到了这个问题。此模型依赖6个表。几乎没有发送命令。有什么建议? 没有错误,因为它没有运行。在Windows和MacOS上运行此功能的其他团队成员希望它在10分钟内完成。目前是30分钟,但我让它坐了更长的时间。 我的命令是 dbt run --models +fct_mymodel --full-refresh --vars "run_date_start: 2020-06-01"

谢谢

解决方法

Redhift UI通常只显示长时间运行的查询。我遇到了类似的问题,它们是由某些表上的锁引起的-在我们的情况下是由于未提交的显式事务({BEGIN而没有COMMITROLLBACK引起的)。

运行此查询以查看当前交易及其锁:

select a.txn_owner,a.txn_db,a.xid,a.pid,a.txn_start,a.lock_mode,a.relation as table_id,nvl(trim(c."name"),d.relname) as tablename,a.granted,b.pid as blocking_pid,datediff(s,getdate())/86400||' days '||datediff(s,getdate())%86400/3600||' hrs '||datediff(s,getdate())%3600/60||' mins '||datediff(s,getdate())%60||' secs' as txn_duration
from svv_transactions a 
left join (select pid,relation,granted from pg_locks group by 1,2,3) b 
on a.relation=b.relation and a.granted='f' and b.granted='t' 
left join (select * from stv_tbl_perm where slice=0) c 
on a.relation=c.id 
left join pg_class d on a.relation=d.oid
where  a.relation is not null;

阅读AWS知识库条目以了解更多详细信息https://aws.amazon.com/premiumsupport/knowledge-center/prevent-locks-blocking-queries-redshift/