前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >ORA-12034: “SCOTT"."USER_TABLE” 上的实体化视图日志比上次刷新后的内容新

ORA-12034: “SCOTT"."USER_TABLE” 上的实体化视图日志比上次刷新后的内容新

作者头像
星哥玩云
发布2022-08-16 13:59:15
7870
发布2022-08-16 13:59:15
举报
文章被收录于专栏:开源部署

最近同事在交接工作时,发现有几个schedule job没有执行成功,我这边给看了下,其中一个是由于数据库迁移,调用dblink的host主机IP在tnsnames中没有变更导致,还有一个是无法视图的报错,即报错信息如下:

一、错误日志

通过查看schedual job报错日志,具体报错信息如下

ORA-12034:"SCOTT"."USER_TABLE" 上的实体化视图日志比上次刷新后的内容新 ORA-06512: 在 "SYS.DBMS_SNAPSHOT", line 2563 ORA-06512: 在 "SYS.DBMS_SNAPSHOT", line 2776 ORA-06512: 在 "SYS.DBMS_SNAPSHOT", line 2745 ORA-06512: 在 line 2

二、错误原因

一般出现这个错误是在刷新物化视图,方式为fast的时候会出现(ORA-12034 is a timing issue that occurs when performing a fast refresh of a materialized view.)

When a materialized view log is created for a master table, and a materialized view has been created with the REFRESH FAST option, the following timestamps will be used when validating log age. At the materialized view site: - Information about the last refresh time for each materialized view. The last refresh time is recorded as the timestamp when the last refresh completed successfully. At the master table site: - Information about the last refresh time for every materialized view using a materialized view log on that site. The timestamps at the master site are used for two purposes: - To maintain information concerning which rows are needed to fast refresh each individual registered materialized view. - To maintain information concerning which rows can be purged from the materialized view log. When a fast refresh starts, the last refresh timestamp from the materialized view site for the refreshing materialized view is compared to the oldest timestamp of ANY materialized view using the same materialized view log as the one currently being refreshed. If the oldest timestamp is newer than the materialized view site timestamp, ORA-12034 is raised. By doing this it is ensured that all changed rows since the last refresh will be refreshed, and if this can't be ensured, a complete refresh is forced. There's no exception to this behavior, and violating this main rule will result ORA-12034.

1、Dropping / recreating the materialized view log on the master table.(在主表上删除或重建物化视图日志)

If a materialized view was created at time T1 and materialized view log was created at time T2, we can't ensure that all changes made between T1 and T2 will be in the materialized view after fast refresh. Therefore complete refresh is mandatory.

2、Creating the materialized view before the materialized view log.(物化视图创建早于物化视图日志)

 The explanation here is the same as in Section 2.1.

3、The previous refresh for the materialized view did not complete successfully.(之前的物化视图刷新没有成功)

When a refresh starts, the last refresh time of the materialized view is set to '01-JAN-1950'. This guarantees that if the refresh fails for any reason, then an ORA-12034 error will be signaled and a complete refresh will be forced. When the refresh succeeds, this date is updated to the proper time. If it doesn't get updated because of some failure during the refresh, the next time the refresh runs, '01-JAN-1950' is used to validate the log age.

4、 Creating a materialized view takes longer than the time it takes all other materialized views currently using the materialized view log to refresh.

If there are other materialized views using the materialized view log on the master table, and all of these other materialized views start their refreshes AFTER the new materialized view creation has started but complete their refreshes BEFORE the new materialized view creation has completed, then fast refreshes will fail with ORA-12034. Materialized view registration is based on the starting time of the creation, but as the last step of the operation. If that start time is older than the oldest timestamp currently registered, the new materialized view will not be registered. A complete refresh is required to register the materialized view, but it may not avoid the ORA-12034 error the next time a fast refresh is attempted.

There are three ways to resolve this problem:

- Stop the refresh of at least one other materialized view that is using the materialized view log before creating the new one. - In production system the previous option might not be possible. For this situation, a temporary materialized view can be created which uses the same log. If this temporary materialized view is not refreshed while the new materialized view is created, the new materialized view creation can complete successfully. - Use deployment templates to create the materialized view environment at materialized view sites. This problem will not occur if deployment templates are used. See the Advanced Replication documentation for information about deployment templates.

5 、Certain DDL changes to the master table have been performed.

6、 Master table reorganization.

7、 Materialized view registration failed at the master site.

 8、Incorrect conversion of a materialized view log from ROWID to primary key.

9、Manual deletion of sys.slog$ entry for the materialized view.

三、解决方案

1、全量刷新物化视图

exec dbms_mview.refresh('SCOTT.USER_TABLE','C');

exec dbms_mview.refresh('SCOTT.USER_TABLE');

2、调整快速舒心日志内容

select * from sys.slog$

SELECT SOWNER, VNAME, MOWNER, MASTER, to_char(SNAPTIME,'yyyy-mm-dd hh24:mi:ss') FROM SYS.SNAP_REFTIME$;

insert into sys.slog$ values('DHSH','USER_BASIC',NULL,171,NULL,to_date('2014-01-07 15:44:18','yyyy-mm-dd hh24:mi:ss'),null,null);

commit;

四、附录

1、MOS方案

    Diagnosing ORA-12034 Materialized View Log Younger Than Last Refresh (文档 ID 204127.1)

(1)Error Definition and Description

Error Definition

Oracle 8i and below: ORA-12034: "snapshot log on "%s"."%s" younger than last refresh" Oracle 9i and above: ORA-12034: "materialized view log on "%s"."%s" younger than last refresh"

Cause: The materialized view log was younger than the last refresh. Action: A complete refresh is required before the next fast refresh.

Note: A complete refresh can be done using the command:

execute dbms_mview.refresh('"CORP"."NM_SV_RANGE"','C');

2、全量刷新物化视图

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
数据传输服务
腾讯云数据传输服务(Data Transfer Service,DTS)可帮助用户在业务不停服的前提下轻松完成数据库迁移上云,利用实时同步通道轻松构建高可用的数据库多活架构,通过数据订阅来满足商业数据挖掘、业务异步解耦等场景需求。同时,DTS 还提供私有化独立输出版本 DTS-DBbridge,支持异构数据库和同构数据库之间迁移和同步,可以帮助企业实现完整数据库迁移(如 Oracle)。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档