Bbed modify undo segment status (ORA-01578), bbedora-01578
ZBDBA@orcl11g>select * from zbdba;select * from zbdba *ERROR at line 1:ORA-01578: ORACLE data block corrupted (file # 3, block # 1449)ORA-01110: data file 3: '/opt/oracle/oradata/orcl11g/undotbs01.dbf'
The transaction is being executed, but the database is shut down in abort mode and the corresponding rollback segment is damaged.
Of course, bbed is not required here. You only need to use the _ offline_rollback_segments implicit parameter to mark the corresponding rollback segment, and then use drop rollback segment to specify the rollback segment.
The purpose of using bbed here is to study where the undo rollback segment is stored and how to modify it.
Here we create another undo tablespace and switch to this tablespace.
ZBDBA@orcl11g>create undo tablespace undotbs02 datafile '/opt/oracle/oradata/orcl11g/undotb02.dbf' size 100m;Tablespace created.ZBDBA@orcl11g>alter system set undo_tablespace=undotbs02;System altered.ZBDBA@orcl11g>show parameter undoNAME TYPE VALUE------------------------------------ ---------------------- ------------------------------undo_management string AUTOundo_retention integer 900undo_tablespace string UNDOTBS02
We checked the status of the rollback segment and found that even if the switch was made, another rollback segment was in the online status because the rollback segment still had data to be restored, however, the rollback segment is damaged and cannot be restored. We can only delete it.
ZBDBA@orcl11g>select segment_name,tablespace_name,status from dba_rollback_segs;SEGMENT_NAME TABLESPACE_NAME STATUS------------------------------ -------------------- ------------------------------------------------------------SYSTEM SYSTEM ONLINE_SYSSMU10_3550978943$ UNDOTBS1 ONLINE_SYSSMU9_1424341975$ UNDOTBS1 OFFLINE_SYSSMU8_2012382730$ UNDOTBS1 OFFLINE_SYSSMU7_3286610060$ UNDOTBS1 OFFLINE_SYSSMU6_2443381498$ UNDOTBS1 OFFLINE_SYSSMU5_1527469038$ UNDOTBS1 OFFLINE_SYSSMU4_1152005954$ UNDOTBS1 OFFLINE_SYSSMU3_2097677531$ UNDOTBS1 OFFLINE_SYSSMU2_2232571081$ UNDOTBS1 OFFLINE_SYSSMU1_3780397527$ UNDOTBS1 OFFLINE_SYSSMU20_3705739785$ UNDOTBS02 ONLINE_SYSSMU19_3920348761$ UNDOTBS02 ONLINE_SYSSMU18_2539622763$ UNDOTBS02 ONLINE_SYSSMU17_178842559$ UNDOTBS02 ONLINE_SYSSMU16_3035903491$ UNDOTBS02 ONLINE_SYSSMU15_444141832$ UNDOTBS02 ONLINE_SYSSMU14_3021863913$ UNDOTBS02 ONLINE_SYSSMU13_3717211136$ UNDOTBS02 ONLINE_SYSSMU12_3182721254$ UNDOTBS02 ONLINE_SYSSMU11_3909920883$ UNDOTBS02 ONLINE
The following shows the status of different numbers:
Undo segment status:
1 indicates offline and deleted
2 indicates offline
3 indicates online
4 unknown
5 indicates need recovery
SYS@orcl11g>select name,status$ from undo$;NAME STATUS$------------------------------------------------------------ ----------SYSTEM 3_SYSSMU1_3780397527$ 2_SYSSMU2_2232571081$ 2_SYSSMU3_2097677531$ 2_SYSSMU4_1152005954$ 2_SYSSMU5_1527469038$ 2_SYSSMU6_2443381498$ 2_SYSSMU7_3286610060$ 2_SYSSMU8_2012382730$ 2_SYSSMU9_1424341975$ 2_SYSSMU10_3550978943$ 3_SYSSMU11_3909920883$ 3_SYSSMU12_3182721254$ 3_SYSSMU13_3717211136$ 3_SYSSMU14_3021863913$ 3_SYSSMU15_444141832$ 3_SYSSMU16_3035903491$ 3_SYSSMU17_178842559$ 3_SYSSMU18_2539622763$ 3_SYSSMU19_3920348761$ 3_SYSSMU20_3705739785$ 3
Force the rollback segment offline and find that the segment cannot be deleted:
SYS@orcl11g>alter rollback segment "_SYSSMU10_3550978943$" offline;Rollback segment altered.SYS@orcl11g>drop tablespace UNDOTBS1;drop tablespace UNDOTBS1*ERROR at line 1:ORA-30013: undo tablespace 'UNDOTBS1' is currently in use
In this case, we disable the database and use bbed to change the status of the rollback segment:
When the database is started, we can track the event of oradebug 10046 by analyzing the trace file:
PARSING IN CURSOR #2 len=142 dep=1 uid=0 oct=3 lid=0 tim=1414654507002840 hv=361892850 ad='78938c58' sqlid='7bd391hat42zk'select /*+ rule */ name,file#,block#,status$,user#,undosqn,xactsqn,scnbas,scnwrp,DECODE(inst#,0,NULL,inst#),ts#,spare1 from undo$ where us#=:1END OF STMTPARSE #2:c=0,e=17,p=0,cr=0,cu=0,mis=0,r=0,dep=1,og=3,plh=906473769,tim=1414654507002839BINDS #2:Bind#0 oacdty=02 mxl=22(22) mxlc=00 mal=00 scl=00 pre=00 oacflg=08 fl2=0001 frm=00 csi=00 siz=24 off=0 kxsbbbfp=7fcf70adc448 bln=22 avl=02 flg=05 value=7
The status of the undo segment is obtained from the undo $ base table. Let's take a look at the physical block number corresponding to the base table here.
SYS@orcl11g>select rowid,dbms_rowid.rowid_object(rowid) robject, 2 dbms_rowid.rowid_relative_fno(rowid) fno, 3 dbms_rowid.rowid_block_number(rowid) bno, 4 dbms_rowid.rowid_row_number(rowid) rno from undo$ where rownum=1;ROWID ROBJECT FNO BNO RNO------------------ ---------- ---------- ---------- ----------AAAAAPAABAAAADhAAA 15 1 225 0
Then we use bbed to view the data block:
BBED> mapFile: /opt/oracle/oradata/orcl11g/system01.dbf (1)Block: 225 Dba:0x004000e1------------------------------------------------------------KTB Data Block (Table/Cluster)struct kcbh, 20 bytes @0 struct ktbbh, 48 bytes @20 struct kdbh, 14 bytes @68 struct kdbt[1], 4 bytes @82 sb2 kdbr[21] @86 ub1 freespace[3752] @128 ub1 rowdata[4308] @3880 ub4 tailchk @8188
Here we can see the 21 rollback segments corresponding to the View:
BBED> p kdbrsb2 kdbr[0] @86 8078sb2 kdbr[1] @88 4071sb2 kdbr[2] @90 5156sb2 kdbr[3] @92 5088sb2 kdbr[4] @94 4206sb2 kdbr[5] @96 4952sb2 kdbr[6] @98 4341sb2 kdbr[7] @100 4816sb2 kdbr[8] @102 4748sb2 kdbr[9] @104 4680sb2 kdbr[10] @106 4611sb2 kdbr[11] @108 4008sb2 kdbr[12] @110 5880sb2 kdbr[13] @112 5817sb2 kdbr[14] @114 5751sb2 kdbr[15] @116 3943sb2 kdbr[16] @118 5622sb2 kdbr[17] @120 3878sb2 kdbr[18] @122 5490sb2 kdbr[19] @124 3812sb2 kdbr[20] @126 5360BBED> p *kdbr[10]rowdata[799]------------ub1 rowdata[799] @4679 0x2cBBED> x /1rnnnnnnnnrowdata[799] @4679 ------------flag@4679: 0x2c (KDRHFL, KDRHFF, KDRHFH)lock@4680: 0x00cols@4681: 17col 0[2] @4682: 10col 1[21] @4685: -0col 2[2] @4707: 1col 3[2] @4710: 3col 4[3] @4713: 272col 5[5] @4717: 5168854col 6[1] @4723: 0col 7[3] @4725: 866col 8[3] @4729: 350col 9[1] @4733: 0col 10[2] @4735: 3col 11[2] @4738: 2col 12[0] @4741: *NULL*col 13[0] @4742: *NULL*col 14[0] @4743: *NULL*col 15[0] @4744: *NULL*col 16[2] @4745: 2
Here, we change the status of the rollback segment to 2, indicating offline
BBED> modify /x 02 offset 4737Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) yFile: /opt/oracle/oradata/orcl11g/system01.dbf (1)Block: 225 Offsets: 4737 to 5248 Dba:0x004000e1------------------------------------------------------------------------0202c103 ffffffff 02c1032c 011102c1 0a145f53 5953534d 55395f31 3432343334313937 352402c1 0202c104 03c20339 05c40614 12210180 03c20b5e 03c2045e018002c1 0302c103 ffffffff 02c1032c 001102c1 09145f53 5953534d 55385f3230313233 38323733 302402c1 0202c104 03c20329 05c40614 11380180 03c20b4003c20334 018002c1 0302c103 ffffffff 02c1032c 001102c1 08145f53 5953534d55375f33 32383636 31303036 302402c1 0202c104 03c20319 05c40614 1135018003c20953 03c20418 018002c1 0302c103 ffffffff 02c1032c 001102c1 07145f535953534d 55365f32 34343333 38313439 382402c1 0202c104 03c20309 05c40220295a0180 03c20944 03c20261 018002c1 0402c103 ffffffff 02c1032c 001102c106145f53 5953534d 55355f31 35323734 36393033 382402c1 0202c104 03c2025d05c40614 11340180 03c20d4c 03c20512 018002c1 0302c103 ffffffff 02c1032c001102c1 05145f53 5953534d 55345f31 31353230 30353935 342402c1 0202c10403c2024d 05c4023e 14400180 03c2084c 03c20461 018002c1 0402c103 ffffffff02c1032c 001102c1 04145f53 5953534d 55335f32 30393736 37373533 312402c10202c104 03c2023d 05c40614 11360180 03c20b5d 03c2053a 018002c1 0302c103ffffffff 02c1032c 001102c1 03145f53 5953534d 55325f32 32333235 37313038<32 bytes per line>BBED> p *kdbr[10]rowdata[799]------------ub1 rowdata[799] @4679 0x2cBBED> x /1rnnnnnnnnrowdata[799] @4679 ------------flag@4679: 0x2c (KDRHFL, KDRHFF, KDRHFH)lock@4680: 0x00cols@4681: 17col 0[2] @4682: 10col 1[21] @4685: -0col 2[2] @4707: 1col 3[2] @4710: 3col 4[3] @4713: 272col 5[5] @4717: 5168854col 6[1] @4723: 0col 7[3] @4725: 866col 8[3] @4729: 350col 9[1] @4733: 0col 10[2] @4735: 1col 11[2] @4738: 2col 12[0] @4741: *NULL*col 13[0] @4742: *NULL*col 14[0] @4743: *NULL*col 15[0] @4744: *NULL*col 16[2] @4745: 2BBED> sum apply;Check value for File 1, Block 225:current = 0x93df, required = 0x93dfBBED> verifyDBVERIFY - Verification startingFILE = /opt/oracle/oradata/orcl11g/system01.dbfBLOCK = 225DBVERIFY - Verification completeTotal Blocks Examined : 1Total Blocks Processed (Data) : 1Total Blocks Failing (Data) : 0Total Blocks Processed (Index): 0Total Blocks Failing (Index): 0Total Blocks Empty : 0Total Blocks Marked Corrupt : 0Total Blocks Influx : 0Message 531 not found; product=RDBMS; facility=BBED
Refresh the cache and re-view the View:
SYS@orcl11g>alter system flush buffer_cache;System altered.SYS@orcl11g>select segment_name,tablespace_name,status from dba_rollback_segs;SEGMENT_NAME TABLESPACE_NAME STATUS------------------------------ -------------------- ------------------------------------------------------------SYSTEM SYSTEM ONLINE_SYSSMU10_3550978943$ UNDOTBS1 OFFLINE_SYSSMU9_1424341975$ UNDOTBS1 OFFLINE_SYSSMU8_2012382730$ UNDOTBS1 OFFLINE_SYSSMU7_3286610060$ UNDOTBS1 OFFLINE_SYSSMU6_2443381498$ UNDOTBS1 OFFLINE_SYSSMU5_1527469038$ UNDOTBS1 OFFLINE_SYSSMU4_1152005954$ UNDOTBS1 OFFLINE_SYSSMU3_2097677531$ UNDOTBS1 OFFLINE_SYSSMU2_2232571081$ UNDOTBS1 OFFLINE_SYSSMU1_3780397527$ UNDOTBS1 OFFLINE_SYSSMU20_3705739785$ UNDOTBS02 ONLINE_SYSSMU19_3920348761$ UNDOTBS02 ONLINE_SYSSMU18_2539622763$ UNDOTBS02 ONLINE_SYSSMU17_178842559$ UNDOTBS02 ONLINE_SYSSMU16_3035903491$ UNDOTBS02 ONLINE_SYSSMU15_444141832$ UNDOTBS02 ONLINE_SYSSMU14_3021863913$ UNDOTBS02 ONLINE_SYSSMU13_3717211136$ UNDOTBS02 ONLINE_SYSSMU12_3182721254$ UNDOTBS02 ONLINE_SYSSMU11_3909920883$ UNDOTBS02 ONLINESYS@orcl11g>select name,status$ from undo$;NAME STATUS$------------------------------------------------------------ ----------SYSTEM 3_SYSSMU1_3780397527$ 2_SYSSMU2_2232571081$ 2_SYSSMU3_2097677531$ 2_SYSSMU4_1152005954$ 2_SYSSMU5_1527469038$ 2_SYSSMU6_2443381498$ 2_SYSSMU7_3286610060$ 2_SYSSMU8_2012382730$ 2_SYSSMU9_1424341975$ 2_SYSSMU10_3550978943$ 1_SYSSMU11_3909920883$ 3_SYSSMU12_3182721254$ 3_SYSSMU13_3717211136$ 3_SYSSMU14_3021863913$ 3_SYSSMU15_444141832$ 3_SYSSMU16_3035903491$ 3_SYSSMU17_178842559$ 3_SYSSMU18_2539622763$ 3_SYSSMU19_3920348761$ 3_SYSSMU20_3705739785$ 3SYS@orcl11g>select name,status$ from undo$;NAME STATUS$------------------------------------------------------------ ----------SYSTEM 3_SYSSMU1_3780397527$ 1_SYSSMU2_2232571081$ 1_SYSSMU3_2097677531$ 1_SYSSMU4_1152005954$ 1_SYSSMU5_1527469038$ 1_SYSSMU6_2443381498$ 1_SYSSMU7_3286610060$ 1_SYSSMU8_2012382730$ 1_SYSSMU9_1424341975$ 1_SYSSMU10_3550978943$ 1_SYSSMU11_3909920883$ 3_SYSSMU12_3182721254$ 3_SYSSMU13_3717211136$ 3_SYSSMU14_3021863913$ 3_SYSSMU15_444141832$ 3_SYSSMU16_3035903491$ 3_SYSSMU17_178842559$ 3_SYSSMU18_2539622763$ 3_SYSSMU19_3920348761$ 3_SYSSMU20_3705739785$ 321 rows selected.
Restart the database and find that the offline rollback segment does not exist:
SYS @ orcl11g> col segment_name for a30; SYS @ orcl11g> col tablespace_name for a30; SYS @ orcl11g> select segment_name, tablespace_name, status from dba_rollback_segs; SEGMENT_NAME TABLESPACE_NAME STATUS when there is a SYSTEM running $ UNDOTBS02 success $ UNDOTBS02 success $ UNDOTBS02 success $ unlock success $ UNDOTBS02 success $ UNDOTBS02 ONLINE at this time let's view the table: SYS @ orcl11g> conn zbdba/oracle; Connected. ZBDBA @ orcl11g> select * from zbdba; NAME ------------------------------------------------------------ zbbda