A log switch is when Oracle stops writing to the current log file, closes it, opens the next log file, and begins writing to the new log file. There are three conditions that cause LGWR to perform. a log switch.
- The normal cause of a log switch is when a process generating redo is unable to allocate space in the log buffer, because there is insufficient space left in the current log file. That process posts LGWR to perform. a log switch, and the session sleeps on a log file switch completion wait event.
- Log switches may be forced manually in the current thread using the ALTER SYSTEM SWITCH LOGFILE command, or in all enabled threads using the ALTER SYSTEM ARCHIVE LOG CURRENT command.
- Log switches may also be forced automatically in relatively idle threads of an Oracle parallel server database, to secure recoverability. Whenever a log file is reused in any thread, the force SCN recorded in the database entry of the controlfile is advanced to 1 beyond the high SCN of the reused log file (unless the force SCN was already higher). If the low SCN for the current log file in any enabled thread thereby falls behind the force SCN, a log switch is forced in that thread. This allows that log file to be archived. Until that log file is archived, newer redo in the archived copy of the recently reused log file might not be able to be applied in some recovery scenarios, or to a standby database.
If a thread requiring a forced log switch is not open, the instance that raised the force SCN will perform. the log switch on behalf of the closed thread, and the first available ARCn process in any instance will archive the log file. However, if the thread is open, its instance is prompted to perform. these actions itself. This is done by taking a KK instance lock. The LGWR process in each instance holds the KK instance lock on its own thread. The id2 field identifies the thread number. When this lock is taken by another instance, LGWR recognizes that a forced log switch is required.
来自 “ ITPUB博客 ” ，链接：http://blog.itpub.net/35489/viewspace-695640/，如需转载，请注明出处，否则将追究法律责任。