Friday, December 31, 2010

Does open database really open?

Ra ra ra, the database has been created, then the tables were created, and even data was entered into the table. Ok, so now I want to shut this thing
down and see if it starts again.

OK, so I shutdown the database, then was about to issue a startup when I thought wait a minute does this thing really open any files when I say open
database.

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.


SQL> startup mount;
ORACLE instance started.

Total System Global Area 2.6991E+10 bytes
Fixed Size                  2213976 bytes
Variable Size            1.7448E+10 bytes
Database Buffers         9395240960 bytes
Redo Buffers              145174528 bytes
Database mounted.
I then found out the process id (PID's) of the Database Writer process.

[root@isvx3 ~]#  ps -ef | grep dbw
oracle    9433     1  0 Dec22 ?        00:00:00 asm_dbw0_+ASM
oracle   32005     1  0 15:43 ?        00:00:00 ora_dbw0_abc
oracle   32007     1  0 15:43 ?        00:00:00 ora_dbw1_abc
oracle   32009     1  0 15:43 ?        00:00:00 ora_dbw2_abc
root     32039 31716  0 15:44 pts/3    00:00:00 grep dbw
Then straced one of the database writed process and collected the output in file.
[root@isvx3 ~]# strace -o /tmp/dbw.txt -p 32005 &
Then I issued the database open command at the sql prompt
SQL> alter database open;

Database altered.

SQL>
Now the moment of truth, Ta-Da....
-bash-3.2$ cat /tmp/dbw.txt | grep open
open("/proc/31987/stat", O_RDONLY)      = 18
open("/u02/app/oracle/oradata/ABC/datafile/o1_mf_system_6kt8jg4q_.dbf", O_RDONLY) = 18
open("/u02/app/oracle/oradata/ABC/datafile/o1_mf_system_6kt8jg4q_.dbf", O_RDONLY) = 18
open("/u02/app/oracle/oradata/ABC/datafile/o1_mf_system_6kt8jg4q_.dbf", O_RDWR|O_SYNC) = 18
open("/u02/app/oracle/oradata/ABC/datafile/o1_mf_sysaux_6kt8jg6r_.dbf", O_RDONLY) = 19
open("/u02/app/oracle/oradata/ABC/datafile/o1_mf_sysaux_6kt8jg6r_.dbf", O_RDONLY) = 19
open("/u02/app/oracle/oradata/ABC/datafile/o1_mf_sysaux_6kt8jg6r_.dbf", O_RDWR|O_SYNC) = 19
open("/u02/app/oracle/oradata/ABC/datafile/o1_mf_undotbs1_6kt8jg8b_.dbf", O_RDONLY) = 20
open("/u02/app/oracle/oradata/ABC/datafile/o1_mf_undotbs1_6kt8jg8b_.dbf", O_RDONLY) = 20
open("/u02/app/oracle/oradata/ABC/datafile/o1_mf_undotbs1_6kt8jg8b_.dbf", O_RDWR|O_SYNC) = 20
open("/u02/app/oracle/oradata/ABC/datafile/o1_mf_users_6kt8jgbw_.dbf", O_RDONLY) = 21
open("/u02/app/oracle/oradata/ABC/datafile/o1_mf_users_6kt8jgbw_.dbf", O_RDONLY) = 21
open("/u02/app/oracle/oradata/ABC/datafile/o1_mf_users_6kt8jgbw_.dbf", O_RDWR|O_SYNC) = 21
open("/u02/app/oracle/oradata/ABC/datafile/foo1.dbf", O_RDONLY) = 22
open("/u02/app/oracle/oradata/ABC/datafile/foo1.dbf", O_RDONLY) = 22
open("/u02/app/oracle/oradata/ABC/datafile/foo1.dbf", O_RDWR|O_SYNC) = 22
open("/u02/app/oracle/oradata/ABC/datafile/o1_mf_temp_6kt8lr7z_.tmp", O_RDONLY) = 23
open("/u02/app/oracle/oradata/ABC/datafile/o1_mf_temp_6kt8lr7z_.tmp", O_RDONLY) = 23
open("/u02/app/oracle/oradata/ABC/datafile/o1_mf_temp_6kt8lr7z_.tmp", O_RDWR|O_SYNC) = 23
open("/u02/app/oracle/product/11.2.0/dbhome_1/rdbms/mesg/oraus.msb", O_RDONLY) = 24
-bash-3.2$
We can see a list of all the files that were opened after open database was called at the sqlplus prompt.

2 comments:

Kyle Hailey said...

nice example. Tried it on on 10.2 on LINUX

open("/oradata/orcl/system01.dbf", O_RDWR|O_SYNC) = 18
open("/oradata/orcl/redo01.log", O_RDWR|O_SYNC) = 18

with filesystemio_options=directio I get

open("/oradata/orcl/system01.dbf", O_RDWR|O_SYNC|O_DIRECT) = 18
open("/oradata/orcl/redo01.log", O_RDWR|O_SYNC|O_DIRECT) = 18

Mayur said...

@Kyle: Thank you for the feedback, and the results of your test.