Oracle:ORA-01555与BLOB
错误,如题所示,具体报错如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
[oracle@DC15VM-032 backup]$ exp system/oracle file=dump_20170817.dmp tables=vcloud.property_map Export: Release 11.2.0.4.0 - Production on Thu Aug 17 18:08:33 2017 Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options Export done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set About to export specified tables via Conventional Path ... Current user changed to VCLOUD . . exporting table PROPERTY_MAP EXP-00056: ORACLE error 1555 encountered ORA-01555: snapshot too old: rollback segment number with name "" too small ORA-22924: snapshot too old Export terminated successfully with warnings. [oracle@DC15VM-032 backup]$ [oracle@DC15VM-032 backup]$ [oracle@DC15VM-032 backup]$ |
看看上面出问题的数据表的详情:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 |
SQL> desc vcloud.property_map Name Null? Type ----------------------------------------- -------- ---------------------------- PM_ID NOT NULL RAW(16) INV_ID NOT NULL RAW(16) VC_ID NOT NULL RAW(16) MOREF NOT NULL VARCHAR2(128) MOTYPE NOT NULL NUMBER(2) AGE NOT NULL NUMBER(10) IS_DELETED NOT NULL NUMBER(1) PROPERTY_MAP NOT NULL BLOB SQL> SQL> set serverout on SQL> exec dbms_output.enable(100000); PL/SQL procedure successfully completed. SQL> declare 2 page number; 3 len number; 4 c varchar2(10); 5 charpp number := 8132/2; 6 7 begin 8 for r in (select rowid rid, dbms_lob.getlength (PROPERTY_MAP) len 9 from vcloud.property_map) loop 10 if r.len is not null then 11 for page in 0..r.len/charpp loop 12 begin 13 select dbms_lob.substr (PROPERTY_MAP, 1, 1+ (page * charpp)) 14 into c 15 from vcloud.property_map 16 where rowid = r.rid; 17 18 exception 19 when others then 20 dbms_output.put_line ('Error on rowid ' ||R.rid||' page '||page); 21 dbms_output.put_line (sqlerrm); 22 end; 23 end loop; 24 end if; 25 end loop; 26 end; 27 / Error on rowid AAAYz8AAGAAABXhAAA page 0 ORA-01555: snapshot too old: rollback segment number with name "" too small ORA-22924: snapshot too old ORA-06512: at "SYS.DBMS_LOB", line 1084 ORA-06512: at line 1 Error on rowid AAAYz8AAGAAABXhAAA page 1 ORA-01555: snapshot too old: rollback segment number with name "" too small ORA-22924: snapshot too old ORA-06512: at "SYS.DBMS_LOB", line 1084 ORA-06512: at line 1 Error on rowid AAAYz8AAGAAABXhAAA page 2 ORA-01555: snapshot too old: rollback segment number with name "" too small ORA-22924: snapshot too old ORA-06512: at "SYS.DBMS_LOB", line 1084 ORA-06512: at line 1 Error on rowid AAAYz8AAGAAABXhAAA page 3 ORA-01555: snapshot too old: rollback segment number with name "" too small ORA-22924: snapshot too old ORA-06512: at "SYS.DBMS_LOB", line 1084 ORA-06512: at line 1 Error on rowid AAAYz8AAGAAABXhAAA page 4 ORA-01555: snapshot too old: rollback segment number with name "" too small ORA-22924: snapshot too old ORA-06512: at "SYS.DBMS_LOB", line 1084 ORA-06512: at line 1 Error on rowid AAAYz8AAGAAABXhAAA page 5 ORA-01555: snapshot too old: rollback segment number with name "" too small ORA-22924: snapshot too old ORA-06512: at "SYS.DBMS_LOB", line 1084 ORA-06512: at line 1 Error on rowid AAAYz8AAGAAABXhAAJ page 0 ORA-01555: snapshot too old: rollback segment number with name "" too small ORA-22924: snapshot too old ORA-06512: at "SYS.DBMS_LOB", line 1084 ORA-06512: at line 1 Error on rowid AAAYz8AAGAAABXhAAJ page 1 ORA-01555: snapshot too old: rollback segment number with name "" too small ORA-22924: snapshot too old ORA-06512: at "SYS.DBMS_LOB", line 1084 ORA-06512: at line 1 Error on rowid AAAYz8AAGAAABXhAAJ page 2 ORA-01555: snapshot too old: rollback segment number with name "" too small ORA-22924: snapshot too old ORA-06512: at "SYS.DBMS_LOB", line 1084 ORA-06512: at line 1 Error on rowid AAAYz8AAGAAABXhAAJ page 3 ORA-01555: snapshot too old: rollback segment number with name "" too small ORA-22924: snapshot too old ORA-06512: at "SYS.DBMS_LOB", line 1084 ORA-06512: at line 1 Error on rowid AAAYz8AAGAAABXhAAJ page 4 ORA-01555: snapshot too old: rollback segment number with name "" too small ORA-22924: snapshot too old ORA-06512: at "SYS.DBMS_LOB", line 1084 ORA-06512: at line 1 Error on rowid AAAYz8AAGAAABXhAAJ page 5 ORA-01555: snapshot too old: rollback segment number with name "" too small ORA-22924: snapshot too old ORA-06512: at "SYS.DBMS_LOB", line 1084 ORA-06512: at line 1 Error on rowid AAAYz8AAGAAAELqAAL page 0 ORA-01555: snapshot too old: rollback segment number with name "" too small ORA-22924: snapshot too old ORA-06512: at "SYS.DBMS_LOB", line 1084 ORA-06512: at line 1 Error on rowid AAAYz8AAGAAAELqAAL page 1 ORA-01555: snapshot too old: rollback segment number with name "" too small ORA-22924: snapshot too old ORA-06512: at "SYS.DBMS_LOB", line 1084 ORA-06512: at line 1 Error on rowid AAAYz8AAGAAAELqAAL page 2 ORA-01555: snapshot too old: rollback segment number with name "" too small ORA-22924: snapshot too old ORA-06512: at "SYS.DBMS_LOB", line 1084 ORA-06512: at line 1 Error on rowid AAAYz8AAGAAAELqAAL page 3 ORA-01555: snapshot too old: rollback segment number with name "" too small ORA-22924: snapshot too old ORA-06512: at "SYS.DBMS_LOB", line 1084 ORA-06512: at line 1 Error on rowid AAAYz8AAGAAAELqAAL page 4 ORA-01555: snapshot too old: rollback segment number with name "" too small ORA-22924: snapshot too old ORA-06512: at "SYS.DBMS_LOB", line 1084 ORA-06512: at line 1 Error on rowid AAAYz8AAGAAAELqAAL page 5 ORA-01555: snapshot too old: rollback segment number with name "" too small ORA-22924: snapshot too old ORA-06512: at "SYS.DBMS_LOB", line 1084 ORA-06512: at line 1 Error on rowid AAAYz8AAGAAAJmQAAl page 0 ORA-01555: snapshot too old: rollback segment number with name "" too small ORA-22924: snapshot too old ORA-06512: at "SYS.DBMS_LOB", line 1084 ORA-06512: at line 1 Error on rowid AAAYz8AAGAAAaMsAAC page 0 ORA-01555: snapshot too old: rollback segment number with name "" too small ORA-22924: snapshot too old ORA-06512: at "SYS.DBMS_LOB", line 1084 ORA-06512: at line 1 Error on rowid AAAYz8AAGAAAaMsAAQ page 0 ORA-01555: snapshot too old: rollback segment number with name "" too small ORA-22924: snapshot too old ORA-06512: at "SYS.DBMS_LOB", line 1084 ORA-06512: at line 1 Error on rowid AAAYz8AAGAAAaMsAAQ page 1 ORA-01555: snapshot too old: rollback segment number with name "" too small ORA-22924: snapshot too old ORA-06512: at "SYS.DBMS_LOB", line 1084 ORA-06512: at line 1 Error on rowid AAAYz8AAGAAAaMsAAQ page 2 ORA-01555: snapshot too old: rollback segment number with name "" too small ORA-22924: snapshot too old ORA-06512: at "SYS.DBMS_LOB", line 1084 ORA-06512: at line 1 Error on rowid AAAYz8AAGAAAaMsAAQ page 3 ORA-01555: snapshot too old: rollback segment number with name "" too small ORA-22924: snapshot too old ORA-06512: at "SYS.DBMS_LOB", line 1084 ORA-06512: at line 1 Error on rowid AAAYz8AAGAAAaMsAAQ page 4 ORA-01555: snapshot too old: rollback segment number with name "" too small ORA-22924: snapshot too old ORA-06512: at "SYS.DBMS_LOB", line 1084 ORA-06512: at line 1 Error on rowid AAAYz8AAGAAAaMsAAQ page 5 ORA-01555: snapshot too old: rollback segment number with name "" too small ORA-22924: snapshot too old ORA-06512: at "SYS.DBMS_LOB", line 1084 ORA-06512: at line 1 Error on rowid AAAYz8AAGAAA4B3AAF page 2 ORA-01555: snapshot too old: rollback segment number with name "" too small ORA-22924: snapshot too old ORA-06512: at "SYS.DBMS_LOB", line 1084 ORA-06512: at line 1 Error on rowid AAAYz8AAGAAA4B3AAF page 3 ORA-01555: snapshot too old: rollback segment number with name "" too small ORA-22924: snapshot too old ORA-06512: at "SYS.DBMS_LOB", line 1084 ORA-06512: at line 1 Error on rowid AAAYz8AAGAAA4B3AAF page 6 ORA-01555: snapshot too old: rollback segment number with name "" too small ORA-22924: snapshot too old ORA-06512: at "SYS.DBMS_LOB", line 1084 ORA-06512: at line 1 Error on rowid AAAYz8AAGAAA4B3AAF page 7 ORA-01555: snapshot too old: rollback segment number with name "" too small ORA-22924: snapshot too old ORA-06512: at "SYS.DBMS_LOB", line 1084 ORA-06512: at line 1 Error on rowid AAAYz8AAGAAA4B3AAF page 8 ORA-01555: snapshot too old: rollback segment number with name "" too small ORA-22924: snapshot too old ORA-06512: at "SYS.DBMS_LOB", line 1084 ORA-06512: at line 1 PL/SQL procedure successfully completed. SQL> |
对于该报错,Oracle Support,也有说明:
ORA-01555 And Other Errors while Exporting Table With LOBs, How To Detect Lob Corruption. (文档 ID 452341.1)
确认到底是那些BLOB有问题:
Code:
————————————
set serverout on
exec dbms_output.enable(100000);
declare
page number;
len number;
c varchar2(10);
charpp number := 8132/2;
begin
for r in (select rowid rid, dbms_lob.getlength (
from
if r.len is not null then
for page in 0..r.len/charpp loop
begin
select dbms_lob.substr (
into c
from
where rowid = r.rid;
exception
when others then
dbms_output.put_line (‘Error on rowid ‘ ||R.rid||’ page ‘||page);
dbms_output.put_line (sqlerrm);
end;
end loop;
end if;
end loop;
end;
/
————————————
创建一个表存放出错的对象的ROWID信息:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
SQL> create table corrupted_lob_data (corrupted_rowid rowid) 2 ; Table created. SQL> set concat off SQL> declare 2 error_1555 exception; 3 pragma exception_init(error_1555,-1555); 4 num number; 5 begin 6 for cursor_lob in (select rowid r, &&lob_column from &table_owner.&table_with_lob) loop 7 begin 8 num := dbms_lob.instr (cursor_lob.&&lob_column, hextoraw ('889911')) ; 9 exception 10 when error_1555 then 11 insert into corrupted_lob_data values (cursor_lob.r); 12 commit; 13 end; 14 end loop; 15 end; 16 / Enter value for lob_column: PROPERTY_MAP Enter value for table_owner: vcloud Enter value for table_with_lob: PROPERTY_MAP old 6: for cursor_lob in (select rowid r, &&lob_column from &table_owner.&table_with_lob) loop new 6: for cursor_lob in (select rowid r, PROPERTY_MAP from vcloud.PROPERTY_MAP) loop old 8: num := dbms_lob.instr (cursor_lob.&&lob_column, hextoraw ('889911')) ; new 8: num := dbms_lob.instr (cursor_lob.PROPERTY_MAP, hextoraw ('889911')) ; PL/SQL procedure successfully completed. SQL> SQL> SQL> select * from corrupted_lob_data; CORRUPTED_ROWID ------------------ AAAYz8AAGAAABXhAAA AAAYz8AAGAAABXhAAJ AAAYz8AAGAAAELqAAL AAAYz8AAGAAAJmQAAl AAAYz8AAGAAAaMsAAC AAAYz8AAGAAAaMsAAQ AAAYz8AAGAAA4B3AAF 7 rows selected. SQL> SQL> |
根据上面的ROWID,去看看能不能导出:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
[oracle@DC15VM-032 blob]$ exp system/oracle file=vcloud-property_map_1.dmp log=vcloud-property_map.log tables=vcloud.property_map query=\"where rowid = \'AAAYz8AAGAAABXhAAA\'\" Export: Release 11.2.0.4.0 - Production on Thu Aug 17 18:38:23 2017 Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options Export done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set About to export specified tables via Conventional Path ... Current user changed to VCLOUD . . exporting table PROPERTY_MAP EXP-00056: ORACLE error 1555 encountered ORA-01555: snapshot too old: rollback segment number with name "" too small ORA-22924: snapshot too old Export terminated successfully with warnings. [oracle@DC15VM-032 blob]$ |
换一种方式试试:
1 2 3 4 5 6 7 8 9 |
SQL> select * from vcloud.property_map where rowid='AAAYz8AAGAAABXhAAA'; ERROR: ORA-01555: snapshot too old: rollback segment number with name "" too small ORA-22924: snapshot too old SQL> SQL> |
很显然是不行的。
修复BLOB带来的问题:
1 2 3 4 5 6 7 8 9 10 11 12 |
SQL> update vcloud.property_map 2 set PROPERTY_MAP = empty_blob() 3 where rowid in (select corrupted_rowid 4 from corrupted_lob_data); commit; 7 rows updated. SQL> Commit complete. SQL> |
再次查看:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
SQL> select * from vcloud.property_map where rowid='AAAYz8AAGAAABXhAAA'; PM_ID INV_ID -------------------------------- -------------------------------- VC_ID -------------------------------- MOREF -------------------------------------------------------------------------------- MOTYPE AGE IS_DELETED ---------- ---------- ---------- PROPERTY_MAP -------------------------------------------------------------------------------- AC66541E91384485BD1290B5D58A4ACD 7D881E44CD714AFAB63EE0E093012EB5 76A56C580A5A4838BB5D264DF56EEA18 vm-54982 PM_ID INV_ID -------------------------------- -------------------------------- VC_ID -------------------------------- MOREF -------------------------------------------------------------------------------- MOTYPE AGE IS_DELETED ---------- ---------- ---------- PROPERTY_MAP -------------------------------------------------------------------------------- 11 61946167 0 SQL> |
问题已经得到修正。
另外,上面为了查找某个USER下有哪些BLOB,我写了一个SQL:
set pagesize 45;
col table_name for a24
col column_name for a24
col owner for a12
select owner|| ‘.’ ||table_name|| ‘.’ ||column_name from dba_tab_columns where owner in (‘VPX’,’VCLOUD’) and DATA_TYPE=’BLOB’;
————————————
Done。
Master Note for ORA-1555 Errors (文档 ID 1307334.1)
LOBs and ORA-01555 troubleshooting (文档 ID 846079.1)
Troubleshooting Assistant: Resolve Issues with Oracle Undo Management (ORA-01555, ORA-30036, ORA-01628, ORA-01552, etc.) (文档 ID 1575667.2)
Export Fails With Errors ORA-2354 ORA-1555 ORA-22924 And How To Confirm LOB Segment Corruption Using Export Utility (文档 ID 833635.1)
ORA-1578 ORA-26040 in a LOB segment – Script to solve the errors (文档 ID 293515.1)
set concat off
declare
error_1555 exception;
pragma exception_init(error_1555,-1555);
num number;
begin
for cursor_lob in (select rowid r, &&lob_column from &table_owner.&table_with_lob) loop
begin
num := dbms_lob.instr (cursor_lob.&&lob_column, hextoraw (‘889911’)) ;
exception
when error_1555 then
insert into corrupted_lob_data values (cursor_lob.r);
commit;
end;
end loop;
end;
还有一个exp的过程忘了写。
IF: ORA-1555 on LOB Data (文档 ID 1950896.1)
另外,由于LOBs产生的ORA-01555的错误,可能并不会在ALERT日志中有所记录与表现。