Home > oracle > Ignore sequence grant error on logical standby

Ignore sequence grant error on logical standby

February 26th, 2010

在10.2版本logical standby环境中,如果primary上执行grant select on sequence to user,这条命令会复制到standby,如果sequence在standby上面不存在,apply process会停止工作。

对于有些部分复制的logical standby来说,需要忽略这部分错误。对于grant select on table to user,oracle已经很聪明的忽略了这类错误,显然grant sequence的问题是设计上的一个bug。

还好我们可以通过dbms_logstdby.skip_error来自动忽略此错误。

首先创建一个procedure用来处理GRANT的DDL 错误

CREATE OR REPLACE PROCEDURE sys.handle_error_ddl (
old_stmt IN VARCHAR2,
stmt_type IN VARCHAR2,
schema IN VARCHAR2,
name IN VARCHAR2,
xidusn IN NUMBER,
xidslt IN NUMBER,
xidsqn IN NUMBER,
error IN VARCHAR2,
new_stmt OUT VARCHAR2

) AS
BEGIN
— Ignore any GRANT errors
new_stmt := old_stmt;
IF INSTR(UPPER(old_stmt),’GRANT’) > 0
THEN
new_stmt := NULL;
END IF;
END handle_error_ddl;
/

然后执行dbms_logstdby.skip_error,当遇到任何Non schema DDL的错误时,调用procedure sys.handle_error_ddl 来处理。

begin
DBMS_LOGSTDBY.SKIP_ERROR (‘NON_SCHEMA_DDL’, ”,”, ‘SYS.HANDLE_ERROR_DDL’);
end;
/

Eagle Fan oracle

  1. Yong Huang
    March 16th, 2010 at 06:31 | #1

    > IF INSTR(UPPER(old_stmt),’GRANT’) > 0

    Don’t you have to be a little more specific than that? What if the SQL is “alter table government_grant add columnname…”?

  2. Eagle Fan
    March 16th, 2010 at 11:08 | #2

    The procedure is only triggered by any *non schema* DDL *error*.

    Alter table is a schema DDL. So it will not be triggered.

  3. yong
    March 17th, 2010 at 02:19 | #3

    How about
    Alter database datafile ‘…/grant_data.dbf’ resize…
    Alter tablespace grant_data …

  4. Eagle fan
    March 17th, 2010 at 22:40 | #4

    If these DDL can execute successfully, it will not trigger the procedure. If it fails, then logical standby will also skip it and put the message in dba_logstdby_events. I think decoding the error may help, but I didn’t do test.

  1. No trackbacks yet.