Presentation is loading. Please wait.

Presentation is loading. Please wait.

10 Managing Rollback Segments. 10-2 Objectives Planning the number and size of rollback segments Creating rollback segments using appropriate storage.

Similar presentations


Presentation on theme: "10 Managing Rollback Segments. 10-2 Objectives Planning the number and size of rollback segments Creating rollback segments using appropriate storage."— Presentation transcript:

1 10 Managing Rollback Segments

2 10-2 Objectives Planning the number and size of rollback segments Creating rollback segments using appropriate storage settings Maintaining rollback segments Obtaining rollback segment information from the data dictionary Troubleshooting rollback segment problems Planning the number and size of rollback segments Creating rollback segments using appropriate storage settings Maintaining rollback segments Obtaining rollback segment information from the data dictionary Troubleshooting rollback segment problems

3 10-3 Rollback Segment (Introduction) Used for delete and update operations only Used to ‘undo’ a transaction Used to save the old value when a process changes data. Stores location and value of data before modification A transaction can use only one rollback segment

4 10-4 Rollback Segment Update transaction Old image New image Rollback segment Table

5 10-5 Rollback Segment (Steps) Data block brought into DB buffer Rollback segment brought into DB buffer Old data written to the rollback segment Update made to data block

6 10-6 Rollback Segments: Purpose Transaction rollback Transaction recovery (when instance fails) Rollback segment Read consistency

7 10-7 Read-Consistency Image at statement commencement New image Table SELECT * FROM table

8 10-8 Read-Consistency When Oracle begins execution of a SELECT statement, it determines the current SCN Ensures that changes not committed before the SCN are not processed by the statement In the case of a long running transaction, Oracle constructs a read-consistent image of the block by retrieving the before-image and applying changes to it in memory

9 10-9 Read-Consistency Read consistency is always provided for a SQL statement Request read consistency for a transaction: SET TRANSACTION READ ONLY; Or SET TRANSACTION SERIALIZABLE;

10 10-10 Types of Rollback Segments SYSTEM: used for objects in the SYSTEM tablespace; created in the SYSTEM ts Non-SYSTEM: objects in other tablespaces – At least one needed – Private: acquire by a single instance – Public: acquired by any instance (used with parallel server) SYSTEM: used for objects in the SYSTEM tablespace; created in the SYSTEM ts Non-SYSTEM: objects in other tablespaces – At least one needed – Private: acquire by a single instance – Public: acquired by any instance (used with parallel server)

11 10-11 Transactions and Rollback Segments Transactions need rollback segments to be assigned: – SET TRANSACTION Use Rollback Segment rbs1 If no request is made, Oracle uses segment with fewest transactions Transactions use extents in a circular fashion More than one transaction can write to the same extent of a segment; however each block contains information from only one transaction Transactions need rollback segments to be assigned: – SET TRANSACTION Use Rollback Segment rbs1 If no request is made, Oracle uses segment with fewest transactions Transactions use extents in a circular fashion More than one transaction can write to the same extent of a segment; however each block contains information from only one transaction

12 10-12 Transactions and Rollback Segments Example Transaction 1 Active extent Inactive extent 43 12 Transaction 2 Begin at extent 3 When full, move to extent 4 (called a wrap) When that fills, can use the 1 st extent if it is free or inactive

13 10-13 Growth of Rollback Segments Active extent Inactive extent 12 43 1 2 3 4 5 New extent Cannot skip an extent; if next extent is being used, an additional extent is allocated. This is called an extend. Can grow this way until it reaches the maximum number of extents specified in the MAXEXTENTS parameter

14 10-14 Shrinkage of Rollback Segments Active extent Inactive extent 12 63 1 2 3 4 5 6 Optimal

15 10-15 Shrinkage of Rollback Segments Deallocation of extents is not done as soon as transactions end. Deallocation performed when head moves from one extent to next and: Current size of rollback segment > OPTIMAL There are contiguous inactive extents

16 10-16 Creating Rollback Segments CREATE ROLLBACK SEGMENT rbs01 TABLESPACE rbs STORAGE ( INITIAL 100K NEXT 100K OPTIMAL 4M MINEXTENTS 20 MAXEXTENTS 100); CREATE ROLLBACK SEGMENT rbs01 TABLESPACE rbs STORAGE ( INITIAL 100K NEXT 100K OPTIMAL 4M MINEXTENTS 20 MAXEXTENTS 100); Example MINEXTENTS: at least 2; PCTINCREASE not specified: always 0 Always use INITIAL = NEXT; OPTIMAL specifies size in bytes that the rollback segment must shrink to, if possible AVOID setting MAXEXTENTS to UNLIMITED: can cause unnecessary extension due to program error

17 10-17 Planning Rollback Segments: Number OLTP – Small, but many segments – One RBS/4 transactions Batch – Large, but few Always place rollback segments in a separate exclusive tablespace Always use INITIAL=NEXT PCTINCREASE cannot be specified (always 0) Set an OPTIMAL value OLTP – Small, but many segments – One RBS/4 transactions Batch – Large, but few Always place rollback segments in a separate exclusive tablespace Always use INITIAL=NEXT PCTINCREASE cannot be specified (always 0) Set an OPTIMAL value

18 10-18 Planning Rollback Segments: Number of Extents 0.000.00 0.100.10 0.200.20 0.300.30 0.400.40 0.500.50 001010202030304040 Number of extents Probability of extending

19 10-19 Bringing Rollback Segments Online Use the following command to make a rollback segment available (when created, they are offline): Specify the following initialization parameter to ensure rollback segments are brought online at STARTUP: Use the following command to make a rollback segment available (when created, they are offline): Specify the following initialization parameter to ensure rollback segments are brought online at STARTUP: ALTER ROLLBACK SEGMENT rbs01 ONLINE; ROLLBACK_SEGMENTS=(rbs01, rbs02)

20 10-20 How Instances Acquire Rollback Segments when DB is opened Bring all acquired RBSs ONLINE Acquire named private RBS Are there enough RBS ? Acquire public RBS Compute required number of RBS Yes No

21 10-21 Changing Rollback Segment Storage Settings ALTER ROLLBACK SEGMENT rbs01 STORAGE( MAXEXTENTS 200 ); ALTER ROLLBACK SEGMENT rbs01 STORAGE( MAXEXTENTS 200 ); Use ALTER ROLLBACK SEGMENT

22 10-22 Manually Deallocating Space from Rollback Segments ALTER ROLLBACK SEGMENT rbs01 SHRINK TO 4M; ALTER ROLLBACK SEGMENT rbs01 SHRINK TO 4M; If OPTIMAL is specified, Oracle will attempt to deallocate Use ALTER ROLLBACK SEGMENT (if extents are active, may not shrink to the requested size) If OPTIMAL is specified, Oracle will attempt to deallocate Use ALTER ROLLBACK SEGMENT (if extents are active, may not shrink to the requested size)

23 10-23 Taking Rollback Segment Offline ALTER ROLLBACK SEGMENT rbs01 OFFLINE; Take a rollback segment offline to make it unavailable.

24 10-24 Dropping Rollback Segments A rollback segment must be offline before it can be dropped. DROP ROLLBACK SEGMENT rbs01;

25 10-25 Rollback Segments in the Database DBA_ROLLBACK_SEGS Identification – SEGMENT_ID – SEGMENT_NAME Location, type, and status – TABLESPACE_NAME – OWNER (PUBLIC or SYS) – STATUS (ONLINE or OFFLINE) DBA_ROLLBACK_SEGS Identification – SEGMENT_ID – SEGMENT_NAME Location, type, and status – TABLESPACE_NAME – OWNER (PUBLIC or SYS) – STATUS (ONLINE or OFFLINE)

26 10-26 Rollback Segments in the Database Select segment_name, tablespace_name, owner, status From dba_rollback_segs; Select segment_name, tablespace_name, owner, status From dba_rollback_segs;

27 10-27 Rollback Segment Statistics V$ROLLNAME USN NAME V$ROLLSTAT USN EXTENTS RSSIZE XACTS OPTSIZE HWMSIZE AVEACTIVE STATUS CUREXT CURBLK

28 10-28 Rollback Segment: Current Activity V$SESSION SADDR USERNAME SID SERIAL# V$TRANSACTION SES_ADDR XIDUSN UBAFIL UBABLK UBASQN UBAREC STATUS USED_UBLK USED_UREC

29 10-29 Rollback Segment Problems Insufficient space for transactions Read-consistency error Blocking transaction Error in taking tablespace offline Insufficient space for transactions Read-consistency error Blocking transaction Error in taking tablespace offline

30 10-30 Insufficient Space for Transactions No space in tablespace to extend – Extend data files – Allow automatic extension of data files – Add data files MAXEXTENTS reached for segment – Increase MAXEXTENTS – Recreate segments with larger extent sizes No space in tablespace to extend – Extend data files – Allow automatic extension of data files – Add data files MAXEXTENTS reached for segment – Increase MAXEXTENTS – Recreate segments with larger extent sizes

31 10-31 Read-Consistency Error (snapshot too old) Image at statement commencement New image Table SELECT * FROM table Reused block A long running Trans Another transaction commits Rollback segment is reused Soln: Higher MINEXTENTS; larger extents; higher OPTIMAL value

32 10-32 Blocking Session Extent 3 Existing extent New extent 41 32 1 2 3 4 5 Blocking session A long running trans keeps an extent occupied and blocks other trans from writing to it; segment keeps extending Soln: DBA intervention

33 10-33 Error in Taking a Tablespace Offline Cannot take tablespace containing active RBS offline Check rollback segments in the tablespace Find active transactions using these rollback segments Find session ID and serial number Terminate the session, if necessary Cannot take tablespace containing active RBS offline Check rollback segments in the tablespace Find active transactions using these rollback segments Find session ID and serial number Terminate the session, if necessary

34 10-34 Summary Creating adequate rollback segments Troubleshooting rollback segment problems Creating adequate rollback segments Troubleshooting rollback segment problems


Download ppt "10 Managing Rollback Segments. 10-2 Objectives Planning the number and size of rollback segments Creating rollback segments using appropriate storage."

Similar presentations


Ads by Google