简体   繁体   English

在teradata中自动释放mload

[英]automatic release mload in teradata

We are implementing data warehouse in teradata and has our stage process to load data from source to teradata using mload utility.我们正在 teradata 中实施数据仓库,并有使用 mload 实用程序将数据从源加载到 teradata 的阶段过程。 Problem we are having is if due to some reason mload was active on the table session fail to load data.我们遇到的问题是,如果由于某种原因 mload 在表会话上处于活动状态,则无法加载数据。 Then 99% we go back and run command release load table name.然后 99% 我们返回并运行命令 release load table name。 This always work and we never had any data loss.这始终有效,我们从未丢失任何数据。

My question is can we automate this process.我的问题是我们可以自动化这个过程。 I have around 50 tables so can i create a script which check if mload is active of these table and release mload if active.我有大约 50 个表,所以我可以创建一个脚本来检查 mload 是否在这些表中处于活动状态,如果处于活动状态则释放 mload。 before actually starting the wf itself.在实际启动 wf 之前。 I can have those scripts as IF load active then release or pass.我可以将这些脚本作为 IF 负载激活然后释放或通过。 I am not able to find how to check if mload is active on table.我无法找到如何检查 mload 在表上是否处于活动状态。

Is there any system table or query which can tell if mload is active on table.是否有任何系统表或查询可以判断 mload 是否在表上处于活动状态。 Please advise.请指教。 Thanks!谢谢!

If your attempt to access the table encounters the error number 2652, Operation not allowed: %DBID.%TVMID is being Loaded , this signifies the table is being loaded or that a previous attempt to load the table failed and has not been resolved.如果您尝试访问该表时遇到错误号2652, Operation not allowed: %DBID.%TVMID is being Loaded ,这表示2652, Operation not allowed: %DBID.%TVMID is being Loaded该表或之前尝试加载该表失败且尚未解决。

With careful planning, you may be able to leverage the presence of the acquisition and application error tables to determine if a MultiLoad lock is present or that a previous MultiLoad had job finished with a non-zero return code.通过仔细规划,您可能能够利用获取和应用程序错误表的存在来确定是否存在 MultiLoad 锁,或者之前的 MultiLoad 是否以非零返回码完成了作业。 The acquisition error table, which is specified as the third table in BEGIN MLOAD command ( et_tname1 ), traps errors that occur during the acquisition phase.获取错误表在BEGIN MLOAD命令 ( et_tname1 ) 中指定为第三个表,用于捕获在获取阶段发生的错误。 The application table, which is specified as the fourth table in the BEGIN MLOAD command ( uv_tname1 ), traps errors encountered during the application phase.应用程序表在BEGIN MLOAD命令 ( uv_tname1 ) 中指定为第四个表,用于捕获在应用程序阶段遇到的错误。

If the UV table is present but contains no records, the multiload likely failed in during acquisition phase.如果UV表存在但不包含任何记录,则多加载可能在采集阶段失败。 You can confirm this by checking for the presence of rows in the 'ET` table.您可以通过检查“ET”表中是否存在行来确认这一点。 In this state, the MultiLoad lock could be released and the error tables removed.在这种状态下,可以释放 MultiLoad 锁并删除错误表。 This would allow the table to be accessed and/or the load step restarted.这将允许访问表和/或重新启动加载步骤。

If the 'UV' table is present and contains rows, the MultiLoad likely failed during the application phase.如果“UV”表存在并且包含行,则 MultiLoad 可能在应用程序阶段失败。 In this state, the MultiLoad lock should not be released nor the error tables removed.在这种状态下,不应释放 MultiLoad 锁,也不应删除错误表。 You should determine the reason for the failure and restart the failed job from the point of failure.您应该确定失败的原因并从失败点重新启动失败的作业。 If you release the MultiLoad lock and/or remove the error tables you may end up with a table in an inconsistent state.如果您释放 MultiLoad 锁和/或删除错误表,您最终可能会得到处于不一致状态的表。 In this state, the table will likely have to be dropped, re-created, and reloaded from source files or backups.在这种状态下,可能必须删除、重新创建和从源文件或备份中重新加载表。

Typically, unless the table was empty to begin with, it is desirable to resolve the failed load job.通常,除非表一开始是空的,否则最好解决失败的加载作业。

Have you considered using the ANSI MERGE statement in your Informatica workflow to avoid this issue in the first place?您是否考虑过首先在 Informatica 工作流程中使用 ANSI MERGE 语句来避免此问题? You gain some of the efficiencies of the MultiLoad utility but your recoverability doesn't leave the table in a locked state like the utility.您获得了 MultiLoad 实用程序的一些效率,但您的可恢复性不会像该实用程序那样使表处于锁定状态。 It may require redesigning your approach in your ETL but something to consider going forward.它可能需要重新设计您在 ETL 中的方法,但需要考虑一些事情。

You can use .LABLES and ACTIVITYCOUNT in order to find if the tables are locked or the help tables exist.您可以使用 .LABLES 和 ACTIVITYCOUNT 来查找表是否已锁定或帮助表是否存在。 Add this at the end/start of your Mload script.将此添加到 Mload 脚本的末尾/开头。

ACTIVITYCOUNT returns the number of records selected/impacted by the previous SQL query. ACTIVITYCOUNT返回由上一个 SQL 查询选择/影响的记录数。

LABEL − Assigns a label to a set of SQL commands. LABEL - 为一组 SQL 命令分配标签。

-- DECLARE RULES OF THE LABES
SELECT TOP 1 * FROM <tablename>;
.IF ACTIVITYCOUNT <> 0 THEN .GOTO RELEASE_MLOAD;

SELECT TOP 1 * FROM UV_<tablename>;
.IF ACTIVITYCOUNT >= 0 THEN .GOTO DROP_UV;

SELECT TOP 1 * FROM ET_<tablename>;
.IF ACTIVITYCOUNT >= 0 THEN .GOTO DROP_ET;

SELECT TOP 1 * FROM WT_<tablename>;
.IF ACTIVITYCOUNT >= 0 THEN .GOTO DROP_WT;

SELECT TOP 1 * FROM LOG_<tablename>;
.IF ACTIVITYCOUNT >= 0 THEN .GOTO DROP_LOG;

-- DECLARE THE LABELS
.LABEL RELEASE_MLOAD
RELEASE MLOAD <tablename>;
.IF ERRORCODE <> 0 THEN .EXIT ERRORCODE;

.LABEL DROP_UV
DROP TABLE UV_<tablename>;
.IF ERRORCODE <> 0 THEN .EXIT ERRORCODE;

.LABEL DROP_ET
DROP TABLE ET_<tablename>;
.IF ERRORCODE <> 0 THEN .EXIT ERRORCODE;

.LABEL DROP_WT
DROP TABLE WT_<tablename>;
.IF ERRORCODE <> 0 THEN .EXIT ERRORCODE;

.LABEL DROP_LOG
DROP TABLE LOG_<tablename>;
.IF ERRORCODE <> 0 THEN .EXIT ERRORCODE;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM