昨天遇到一个问题oracle 19c(19.10), 最近一段时间的RMAN备份任务都失败了,错误中有ORA-00230: operation disallowed: snapshot control file enqueue unavailable, 看着是cf的enqueue请求失败。 处理起来比较简单,找到blocker session就可以解决了, 之前的记录过一些分析方法,本次的案例当前还没有匹配的已知bug,这里简单的记录。
RMAN: Backup Fails with ORA-230 Snapshot Controlfile Enqueue Unavailable [ID 145619.1]
分享过一个SQL:
-- Execute the following query to determine which job is causing the wait
SELECT s.sid, username AS "User", program, module, action, logon_time "Logon", l.*
FROM v$session s, v$enqueue_lock l
WHERE l.sid = s.sid and l.type = 'CF' AND l.id1 = 0 and l.id2 = 2;
这里确实可以找到是一个M002进程,但表示是什么意思? ID2 = 2是什么意思? 不确认的事情尽量不要操作,我们尝试手动备份一下问题是不是真的存在hang,比如备份一个spfile。
oracle@anbob1:/home/oracle> rman target / debug trace=rman_debug.log
RMAN> show all;
using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name PRIBILL are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF;
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 10 BACKUP TYPE TO BACKUPSET;
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE RMAN OUTPUT TO KEEP FOR 7 DAYS; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '+ARCHDG/xxxxxxx.f';
RMAN> backup spfile format '/home/oracle/spfile_bak_f';
RMAN-03090: Starting backup at 11-APR-22
RMAN-12016: using channel ORA_DISK_1
RMAN-12016: using channel ORA_DISK_2
RMAN-12016: using channel ORA_DISK_3
RMAN-12016: using channel ORA_DISK_4
RMAN-12016: using channel ORA_DISK_5
RMAN-12016: using channel ORA_DISK_6
RMAN-12016: using channel ORA_DISK_7
RMAN-12016: using channel ORA_DISK_8
RMAN-12016: using channel ORA_DISK_9
RMAN-12016: using channel ORA_DISK_10
RMAN-08008: channel ORA_DISK_1: starting full datafile backup set
RMAN-08010: channel ORA_DISK_1: specifying datafile(s) in backup set
RMAN-08113: including current SPFILE in backup set
RMAN-08038: channel ORA_DISK_1: starting piece 1 at 11-APR-22
RMAN-08044: channel ORA_DISK_1: finished piece 1 at 11-APR-22
RMAN-08530: piece handle=/home/oracle/spfile_bak_f tag=TAG20220411T173319 comment=NONE
RMAN-08540: channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
RMAN-03091: Finished backup at 11-APR-22
RMAN-03090: Starting Control File and SPFILE Autobackup at 11-APR-22
-- hang
^C
debug trace
RMAN-03090: Starting Control File and SPFILE Autobackup at 11-APR-22
DBGMISC: ENTERED krmicomp [17:33:21.598]
DBGANY: trying implicit resync before compiling command Control File and SPFILE Autobackup [17:33:21.598]
...
DBGPLSQL: the compiled command tree is: [17:33:21.768] (krmicomp)
DBGPLSQL: 1 CMD type=Control File and SPFILE Autobackup cmdid=1 status=NOT STARTED
DBGPLSQL: 1 STEPstepid=1 cmdid=1 status=NOT STARTED
DBGPLSQL: 1 TEXTNOD = declare
DBGPLSQL: 2 TEXTNOD = ncopies number;
DBGPLSQL: 3 TEXTNOD = copyno number;
DBGPLSQL: 4 TEXTNOD = handle varchar2(512);
...
DBGPLSQL: 31 TEXTNOD =
DBGPLSQL: 32 PRMVAL = rsid := 51096; rsts := 1101749601;
DBGPLSQL: 33 TEXTNOD = setBackupParams(FALSE);
DBGPLSQL: 34 TEXTNOD = if (krmicd.getParams(1, p2, p3, p4, p5, t1, t2, t3)) then
DBGPLSQL: 35 TEXTNOD = p1 := 1;
DBGPLSQL: 36 TEXTNOD = end if;
DBGPLSQL: 37 TEXTNOD = sys.dbms_backup_restore.setRmanStatusRowId(rsid=>rsid, rsts=>rsts);
DBGPLSQL: 38 TEXTNOD =
DBGPLSQL: 39 TEXTNOD = <> -- retry on failure to get snapshot enqueue
DBGPLSQL: 40 TEXTNOD = begin
DBGPLSQL: 41 TEXTNOD = sys.dbms_backup_restore.DoAutobackup(ncopies => ncopies,
DBGPLSQL: 42 TEXTNOD = cfaudate => lcfaudate,
DBGPLSQL: 43 TEXTNOD = seq => lsequence,
DBGPLSQL: 44 TEXTNOD = format =&