In this post, I am going to include some lessons learned from implementing "Restore as encrypted" of a large database with over 500,000 objects.
The error we were receiving when trying open our database was
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-00603: ORACLE server session terminated by fatal error
ORA-01092: ORACLE instance terminated. Disconnection forced
ORA-00604: error occurred at recursive SQL level 1
ORA-25153: Temporary Tablespace is Empty
Process ID: 133196
Session ID: 1769 Serial number: 6805
And in the alert log we saw.
Parallel first-pass transaction recovery timed out. Switching to serial recovery.
Undo initialization recovery: Parallel FPTR failed: start:685625075 end:685692452 diff:67377 ms (67.4 seconds)
2021-08-27T10:02:39.567998-04:00
Undo initialization recovery: err:0 start: 685625075 end: 685693406 diff: 68331 ms (68.3 seconds)
2021-08-27T10:02:43.015891-04:00
[339055] Successfully onlined Undo Tablespace 17.
Undo initialization online undo segments: err:0 start: 685693406 end: 685696854 diff: 3448 ms (3.4 seconds)
Undo initialization finished serial:0 start:685625075 end:685697235 diff:72160 ms (72.2 seconds)
Dictionary check beginning
2021-08-27T10:02:44.819881-04:00
TT03 (PID:360221): Sleep 80 seconds and then try to clear SRLs in 6 time(s)
2021-08-27T10:02:54.759120-04:00
Tablespace 'PSAPTEMP' #3 found in data dictionary,
but not in the controlfile. Adding to controlfile.
2021-08-27T10:02:55.826700-04:00
Errors in file /u02/app/oracle/diag/rdbms/bsg/BSG1/trace/BSG1_ora_339055.trc:
ORA-00604: error occurred at recursive SQL level 1
ORA-25153: Temporary Tablespace is Empty
2021-08-27T10:02:55.826827-04:00
Errors in file /u02/app/oracle/diag/rdbms/bsg/BSG1/trace/BSG1_ora_339055.trc:
ORA-00604: error occurred at recursive SQL level 1
What we found is that there some work the database has to do when opening for the first time after encrypting tablespaces offline.
Background:
Movement of data to disk that includes any objects that reside in an encrypted tablespace is encrypted. This means that if an object resides in an encrypted tablespace, the following data is also encrypted.
- TEMP - If an object resides in an encrypted tablespace, any sort information in the TEMP tablespace is encrypted. This includes joins to other tables. Any piece of data in a sort operation on disk causes the whole set of data to be encrypted.
- UNDO - If an object resides in an encrypted tablespace, the blocks stored in UNDO are encrypted.
- REDO/Archive - If an object resides in an encrypted tablespace, the changes to that object are encrypted in the redo stream (including redo sent through the network to a standby database).
How this happens:
The way the database manages encryption is to internally mark an object as an encrypted object so that it ensures the objects data stays encrypted on disk.
Now back to "restore as encrypted". Since we restored the database and encrypted the tablespaces, the database needs to mark all the objects in the "newly encrypted" tablespaces as encrypted.
This is part of the database open operation. The open database operation will sort through the internal object metadata to determine what objects now reside in "newly encrypted" tablespaces.
There are a few things to be aware of around this process.
- It requires a sorting of objects. Because of this you may need a much bigger sort_area_size or PGA_TARGET. This is only needed to open the database after encrypting, but this was cause of the issue I was seeing.
- It may take some time. Lots of time depending on the # of objects.
How to mitigate it:
Since we know this is going to happen, there are a few ways to mitigate it.
- Empty out your recycle bin to limit the # of objects to update.
- Proactively increase your PGA (or sort_area_size) for opening the database for the first time after encrypting.
- Encrypt the database in sections. Do not encrypt every tablespace at once to decrease the # of objects that will be marked encrypted. After encrypting a tablespace, open the database, shut it and do the next tablespace. NOTE: this may not be practical.
- Encrypt the tablespace online, as this will mark object as the processing of each tablespace completes.
- Check the number of objects that will need to be updated. This can be done by look at the TAB$ internal table using the TS# matching to the tablespaces that will be encrypted.
NOTE:
Remember a standby database may also have this same issue when opened up read only.
Also, it is possible to have the Primary Database encrypted, and the Standby database unencrypted. Or the opposite if encrypting your standby database first. Restoring from encrypted --> unencrypted or unencrypted --> encrypted and opening up the database will cause this update of metadata to occur.
No comments:
Post a Comment