0% found this document useful (0 votes)
78 views21 pages

Pres4-Oracle Process Structure

Oracle processes include client processes, background processes, and server processes. Background processes like SMON, PMON, DBWn, LGWR, and CKPT perform maintenance tasks when the database instance starts. Server processes handle client requests by parsing SQL, executing plans, and retrieving data. Client processes run user applications connected to the database.

Uploaded by

Abdul Waheed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
78 views21 pages

Pres4-Oracle Process Structure

Oracle processes include client processes, background processes, and server processes. Background processes like SMON, PMON, DBWn, LGWR, and CKPT perform maintenance tasks when the database instance starts. Server processes handle client requests by parsing SQL, executing plans, and retrieving data. Client processes run user applications connected to the database.

Uploaded by

Abdul Waheed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 21

Oracle Process Structure

Introduction to Processes

• A process is a mechanism in an operating


system that can run a series of steps.
• The mechanism depends on the operating
system. For example, on Linux an Oracle
background process is a Linux process.
• On Windows, an Oracle background process is
a thread of execution within a process.
Types of Processes

• A database instance contains or interacts with the following


types of processes:
– Client processes run the application or Oracle tool code.
– Oracle processes run the Oracle database code. Oracle processes
including the following subtypes:
• Background processes start with the database instance and perform
maintenance tasks such as performing instance recovery, cleaning up
processes, writing redo buffers to disk, and so on.
• Server processes perform work based on a client request.
– For example, these processes parse SQL queries, place them in the shared pool,
create and execute a query plan for each query, and read buffers from the database
buffer cache or from disk.
• Slave processes perform additional tasks for a background or server
process.
Client Processes

• When a user runs an application such as a


Pro*C program or SQL*Plus, the operating
system creates a client process (sometimes
called a user process) to run the user
application.
• The client application has Oracle Database
libraries linked into it that provide the APIs
required to communicate with the database.
Server Processes

• Oracle Database creates server processes to handle the


requests of client processes connected to the instance.
• Server processes created on behalf of a database application
can perform one or more of the following tasks:
– Parse and run SQL statements issued through the application,
including creating and executing the query plan
– Execute PL/SQL code
– Read data blocks from data files into the database buffer cache (the
DBWn background process has the task of writing modified blocks
back to disk)
– Return results in such a way that the application can process the
information
Foreground Process
• Started when a used connects to the database
– Foreground Process checks user’s permission
• to access data
• generating query
• Retrieving data blocks into buffer cache and modifying
them
– Before modifying creates copy of data for undo
– Creates entries for undo/redo log
– It terminates when a user session is terminated
Background Process
• The instance background processes are the processes that are launched
when the instance is started and run until it is terminated.
– Mandatory Background Processes
• System Monitor (SMON)
• Process Monitor (PMON)
• Database Writer (DBWn)
• Log Writer (LGWR)
• Checkpoint Process (CKPT)
• Manageability Monitor Processes (MMON and MMNL)
• Recoverer Process (RECO)
– Optional Background Processes
• Archiver Processes (ARCn)
• Job Queue Processes (CJQ0 and Jnnn)
• Flashback Data Archiver Process (FBDA)
• Space Management Coordinator Process (SMCO)
SMON, the System Monitor
• The system monitor process (SMON) is in charge of
a variety of system-level cleanup duties.
• The duties assigned to SMON include:
– Performing instance recovery at instance startup. 
• In an Oracle RAC database, the SMON process of one database
instance can perform instance recovery for a failed instance.
– Recovering terminated transactions that were skipped
during instance recovery because of file-read or
tablespace offline errors.
• SMON recovers the transactions when the tablespace or file is
brought back online.
– Cleaning up unused temporary segments.
• For example, Oracle Database allocates extents when
creating an index. If the operation fails, then SMON
cleans up the temporary space.
• SMON checks regularly to see whether it is
needed. Other processes can call SMON if
they detect a need for it.
Process Monitor Process (PMON)

• The process monitor (PMON) monitors the other


background processes and performs process
recovery when a server process terminates
abnormally.
• PMON monitors all the server processes and detects
any problems with the sessions.
– If a session has terminated abnormally, PMON will
destroy the server process, return its PGA memory to the
operating system’s free memory pool, and roll back any
incomplete transaction that may have been in progress.
DBWn, the Database Writer
• The database writer process (DBWn) writes the contents of
database buffers to data files.
– DBWn processes write modified buffers in the database buffer cache to disk
• It is possible for an instance to have several database writers (up to
a maximum of twenty), which will be called DBW0, DBW1, and so on
• The DBWn process writes dirty buffers to disk under the following
conditions:

– No free buffers
– Too many dirty buffers
– A three second timeout
– A checkpoint occurs
Log Writer (LGWR)
• LGWR writes the contents of the log buffer to the
online log files on disk. A write of the log buffer
to the online redo log files is often referred to as
flushing the log buffer.
• When a session makes any change (by executing
INSERT, UPDATE, or DELETE commands) to blocks
in the database buffer cache, before it applies
the change to the block it writes out the change
vector that it is about to apply to the log buffer.
Log Writer (LGWR)
– The Log Writer (LGWR) transfers all the undo/redo entries
in the log buffer to the redo log files
– When a session issues a COMMIT, the LGWR writes in real
time: the session hangs while LGWR writes
– LGWR is an ultimate bottleneck in the Oracle performance.
– There three conditions that will cause LGWR to execute
• Write on commit
• If Log buffer one-third full
• If DBWr is about to write dirty buffers
– The Archiver (ARCH) makes copies of redo log files when
they fill up
the Checkpoint Process
• after a crash, all change vectors referring to
dirty buffers must be extracted from the redo
log, and applied to the data blocks. This is the
recovery process.
• The incremental checkpoint mechanism
instructs DBWn to write out dirty buffers at a
constant rate.
MMON, the Manageability Monitor

• The database instance gathers a vast number


of statistics about activity and performance.
• MMON regularly captures statistics from the
SGA and writes them to the data dictionary,
where they can be stored indefinitely.
• Every time MMON gathers a set of statistics
(known as a snapshot), it also launches the
Automatic Database Diagnostic Monitor, the
ADDM.
– The ADDM is a tool that analyses database activity
using an expert system.
• It observes two snapshots (the current and
previous snapshots) and makes observations
and recommendations regarding performance.
MMNL, the Manageability Monitor Light

• MMNL is a process that assists the MMON. There


are times when MMON’s scheduled activity is not
enough.
– For example, MMON flushes statistical information
accumulated in the SGA to the database according to a
schedule: by default, every hour.
• If the memory buffers used to accumulate this
information fill before MMON is due to flush them,
MMNL will take responsibility for flushing the data.
ARCn, the Archiver
• Without one or more ARCn processs (there
can be from one to thirty, named ARC0, ARC1,
and so on) it is possible to lose data.
• In order to preserve a complete history of all
changes applied to the data, the online log
files must be copied as they are filled and
before they are reused. The ARCn is
responsible for doing this.
RECO, the Recoverer Process
• The Recoverer process is used by the Oracle
distributed transaction facility to recover from
failures involving distributed transactions by:
– Connecting to other databases involved in the
distributed transaction
– Removing rows corresponding to any in-doubt
transaction from each database’s transaction table
• A distributed transaction is a transaction that
involves updates to two or more databases.
 update employees set salary=salary * 1.1 where
employee_id=1000;
 update employees@dev set salary=salary * 1.1
where employee_id=1000;
 commit;
• The first update applies to a row in the local
database; the second applies to a row in a
remote database identified by the database link
DEV.

You might also like