After completing this lesson, you should be able to do the following: • Create rollback segments using appropriate storage settings • Maintain rollback segments • Plan the number and si
Trang 1B
Manually Managing Undo Data
(Rollback Segments)
Trang 2After completing this lesson, you should be able to do the following:
• Create rollback segments using appropriate storage
settings
• Maintain rollback segments
• Plan the number and size of rollback segments
• Troubleshoot common rollback segment problems
Trang 3Creating Rollback Segments
CREATE ROLLBACK SEGMENT rbs01
TABLESPACE rbs
STORAGE (
INITIAL 100K
MINEXTENTS 20
MAXEXTENTS 100
OPTIMAL 2000K );
Trang 4Transactions and Rollback Segments
Transaction 1
Active extent Inactive extent
Transaction 2
Trang 5Growth of Rollback Segments
Active extent Inactive extent
3 4
5
New extent
Trang 6Shrinkage of Rollback Segments
Active extent Inactive extent
1
2 3
4 5
6
OPTIMAL
Trang 7Bringing Rollback Segments Online
• Use the following command to make a rollback
segment available:
–
• Specify the following initialization parameter to
ensure that rollback segments are brought online at startup:
ROLLBACK_SEGMENTS=(rbs01, rbs02)
ALTER ROLLBACK SEGMENT rbs01 ONLINE;
Trang 8How Instances Acquire Rollback Segments
Bring all acquired rollback segments
online.
Acquire
named private
rollback
segments.
Are there enough RBS’s?
Acquire public rollback segments.
Compute the required number
of rollback segments.
Yes
No
Trang 9Changing Rollback Segment
Storage Settings
• Use the ALTER ROLLBACK SEGMENT command.
• You can change OPTIMAL or MAXEXTENTS.
ALTER ROLLBACK SEGMENT rbs01
STORAGE( MAXEXTENTS 200 );
Trang 10Deallocating Space From
Rollback Segments
• Use the ALTER ROLLBACK SEGMENT command.
• If extents are active, they might not shrink to the
requested size.
ALTER ROLLBACK SEGMENT rbs01
SHRINK TO 4M;
Trang 11Taking Rollback Segment Offline
• Take a rollback segment offline to make it
unavailable.
• If transactions are using the rollback segment, the
status is temporarily changed to PENDING OFFLINE ALTER ROLLBACK SEGMENT rbs01
OFFLINE;
Trang 12Dropping Rollback Segments
• A rollback segment must be offline before it can be
dropped.
DROP ROLLBACK SEGMENT rbs01;
Trang 13Planning Rollback Segments: Number
• OLTP
– Many small rollback segments
– Four transactions per rollback segment
– Up to ten transactions per rollback segment
• Batch
– Few large rollback segments
– One per transaction
Trang 14Planning Rollback Segments:
Number of Extents
0.00 0.10 0.20 0.30 0.40 0.50
Probability
of extending
Trang 15Rollback Segment Problems
• Insufficient space for transactions
• Read-consistency errors
• Blocking sessions
• Errors in taking a tablespace offline
Trang 16Insufficient Space for Transactions
• No space in tablespace:
– Extend data files
– Enables automatic extension of data files
– Add data files
• MAXEXTENTS reached for segment
– Increase MAXEXTENTS
– Re-create segments with larger extent sizes
Trang 17New image
Table FROM table SELECT *
Read-Consistency Errors
Reused block
Trang 18Blocking Sessions
Extent 3
Existing extent
3 4
5
Blocking session
Trang 19Errors in Taking a Tablespace Offline
You cannot take a tablespace offline if it contains an active rollback segment.
1 Determine which rollback segments are in the tablespace.
2 Take all of these rollback segments offline.
3 Find active transactions using these rollback
segments.
4 Find the session ID and serial number.
5 Terminate the session, if necessary.
6 Take the tablespace offline.