ORA-12034: The materialized view log on SCOTT. "USER_TABLE" is newer than the last refresh

Source: Internet
Author: User

ORA-12034: The materialized view log on SCOTT. "USER_TABLE" is newer than the last refresh

Recently, when I handed over my work, I found that several schedule jobs were not successfully executed. I have shown that one of them is due to database migration, if the IP address of the host that calls dblink is not changed in tnsnames, an error cannot be reported in view. The error message is as follows:

I. Error Log

View the error log of schedual job. The error message is as follows:

ORA-12034: The materialized view log on "SCOTT". "USER_TABLE" is newer than the last refresh
ORA-06512: In "SYS. DBMS_SNAPSHOT", line 2563
ORA-06512: In "SYS. DBMS_SNAPSHOT", line 2776
ORA-06512: In "SYS. DBMS_SNAPSHOT", line 2745
ORA-06512: In line 2

Ii. Cause of error

Usually this error occurs when the materialized view is refreshed and the method is fast (ORA-12034 is a timing issue that occurs when refreshing 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 results ORA-12034.

1. Dropping/recreating the materialized view log on the master table. (delete or recreate 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. (materialized view creation is earlier than 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. (The previous materialized view refresh failed)

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 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 med.

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.

Iii. Solutions

1. Refresh the Materialized View

Exec dbms_mview.refresh ('Scott. USER_TABLE ', 'C ');


Exec dbms_mview.refresh ('Scott. USER_TABLE ');

2. Adjust quick and comfortable log Content

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 ('2017-01-07 15:44:18', 'yyyy-mm-dd hh24: mi: ss'), null, null );
Commit;

Iv. Appendix

1. MOS Solution

Diagnosing ORA-12034 Materialized View Log Younger Than Last Refresh (Document 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. Refresh the materialized view in full Mode

Https://www.bkjia.com/topicnews.aspx? Tid = 12

This article permanently updates link: https://www.bkjia.com/Linux/2018-03/151121.htm

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.