July 2010
M T W T F S S
« Apr    
 1234
567891011
12131415161718
19202122232425
262728293031  

PL/Flow — an WfMC-based Workflow implementation using PL/SQL

PL/SQL is a native language of Oracle, it’s an effective way to manipulate Oracle.  A lot of work can be done through PL/SQL programming, even workflow engine, which is usually implemented in Java.

PL/FLOW is an workflow engineer written in PL/SQL. Also it’s located in sourceforge: http://plflow.sourceforge.net/. This project is based on WfMC(Workflow Management Coalition), which is a standard for workflow engine.

Several years ago, I studied WfMC with some classmates, and chose OBE(Open Business Engine,http://obe.sourceforge.net/), a Java-based implementation of WfMC.  Configuration and reading OBE was so puzzled, because OBE used a lot of Java frameworks, such as log4j,velocity, JGraph etc. etc. But this PL/SQL based implementation seems "simple", having extremely less code than OBE. just some tables, indexes, sequences, triggers, procedures.

The core for workflow is the transitions of various states, which is defined by WfMC:

image

The implementation of transitions is realized in procedure "ChangeActivityInstanceState", which has several sub-procedures to start, release, suspend, resume, complete, abort, terminate the activities.

The workflow engine can also accessed by web, through PHP using OCI.

image

image

So, this project is a excellent reference to construct your own workflow engine, pl/sql and PHP programming.

SQL Trace Goes Easier with SQLGotcha

It should be boring to trace session with the session_id and serial#, as we will have to query the v$session firstly using other information we knew, such as username, osuser, program, machine, and sometimes, we will query v$sqltext for db objects the session acessed,  or query v$process with the session’s corresponding process’s pid. This staff are so cumbersome. And, it should be an good idea to record down the sql trace history to further reference.

Life goes easy with SQLGotcha, an open source project located in http://sourceforge.net/projects/sqlgotcha.

All the cumbersome work have been done by SQLGotcha.

Examples

For example, if you want to do a standard trace for users that login with the username APPUSER, you start the trace as follows:

   1: exec sql_gotcha_pack.start_trace_for_session ('USERNAME','APPUSER'); 

If you want to wait 60 seconds for this session to come up, do:

exec sql_gotcha_pack.start_trace_for_session ('USERNAME','APPUSER', 'STANDARD', 0, NULL, 60); 

On Real Application Clusters you’ll find that there is another difficulty in searching sessions. If users connect via a load balanced connection, the session you look for can be on any of the RAC instances. When searching for a session, SQLGotcha can look on other instances than the one you’re connected to with, but it can only mention that a session is elsewhere:

exec sql_gotcha_pack.start_trace_for_session ('USERNAME','APPUSER', 'STANDARD', 0, 'OTHER_INST', 60);

Suppose you’ve run Unix’ top and found out that process 13245 is taking 30% CPU. You want to see every detail, so you choose event 10046 tracing, level 8. You can do this as follows:

exec sql_gotcha_pack.start_trace_for_session ('PID','13245', 10046, 8);

Next you’re visited by an application administrator who asks you to find out why a certain part of the application is slow. All he knows is that the package app_pack is involved. You trace this as folows:

exec sql_gotcha_pack.start_trace_for_session ('OBJECT','APP_PACK', 10046, 8, NULL, 600);

Trace user HSIMPSON who connects from the machine evergreen. max_dump_file_size=2000

exec sql_gotcha_pack.search_and_trace_session('USERNAME=HSIMPSON, MACHINE=evergreen', 10046, 12, 2000);
exec sql_gotcha_pack.end_trace_session('USERNAME=HSIMPSON, MACHINE=evergreen'); 

Trace user TOAD, osuser hsimpson, who logged on with TOAD.exe.

exec sql_gotcha_pack.search_and_trace_session('USERNAME=TOAD, OSUSER=hsimpson, PROGRAM=TOAD.exe', 10046, 12);
exec sql_gotcha_pack.end_trace_session('USERNAME=TOAD, OSUSER=hsimpson, PROGRAM=TOAD.exe');

Wait 60 seconds for user GBURNS to log on.

exec sql_gotcha_pack.search_and_trace_session('USERNAME=GBURNS', 0, NULL, NULL, 60);
exec sql_gotcha_pack.end_trace_session('USERNAME=GBURNS');

And, the table sqlgotcha_trace_log can be used to query the history of sql traces.

sqlgotcha@ORCL> select sid,serial#,search_type,search_for,trace_type,trace_filename from sqlgotcha_trace_log;

       SID    SERIAL# SEARCH_TY SEARCH_FOR                     TRACE_TYPE TRACE_FILENAME
---------- ---------- --------- ------------------------------ ---------- --------------------
       124       2731 PROGRAM   SQLPLUS                        STANDARD   orcl_ora_7414.trc
       125       2861 PROGRAM   SQLPLUS                        STANDARD   orcl_ora_7428.trc
       105       2725 USERNAME  PLFLOW                         STANDARD   orcl_ora_2764.trc
       124      14128 USERNAME  PLFLOW                         STANDARD   orcl_ora_3509.trc

OCFS2 vs RAW vs EXT 2/3

Introduction to OCGF2

OCFS2 is the next generation of the Oracle Cluster File System for Linux. It is an extent based, POSIX compliant file system. Unlike the previous release (OCFS), OCFS2 is a general-purpose file system that can be used for shared Oracle home installations making management of Oracle Real Application Cluster (RAC) installations even easier. Among the new features and benefits are:

  1. Node and architecture local files using Context Dependent Symbolic Links (CDSL) (symbolic link to different file on different hostname/architecture)
  2. Network based pluggable DLM (distributed lock management)
  3. Improved journaling / node recovery using the Linux Kernel "JBD" subsystem
  4. Improved performance of meta-data operations (space allocation, locking, etc).
  5. Improved data caching / locking (for files such as oracle binaries, libraries, etc)

OCFS2 comes bundled with its own cluster stack, O2CB. The stack includes:

  1. NM: Node Manager that keep track of all the nodes in the cluster.conf
  2. HB: Heart beat service that issues up/down notifications when nodes join or leave the cluster
  3. TCP: Handles communication between the nodes
  4. DLM: Distributed lock manager that keeps track of all locks, its owners and status
  5. CONFIGFS: User space driven configuration file system mounted at /config
  6. DLMFS: User space interface to the kernel space DLM

O2CB instance runs on each node, and provides the read/write and lock control for nodes access, throught network communication.

ORACLE SUPPORT AND CERTIFICATION

OCFS2 1.2.3 or later is certified with Oracle 10gR2 RAC on the x86 and x86-64 platforms on Enterprise Linux 4.  Users can download the packages from the Unbreakable Linux Network site.

OCFS2 1.2.1 or later is certified with Oracle 10gR2 RAC on the x86, x86-64, IA64, PPC64 and s390x platforms on Red Hat’s RHEL4 Updates 2 and higher. Users can download the packages from here.

OCFS2 1.2.1 or later is certified with Oracle 10gR2 RAC on the x86, x86-64, IA64, PPC64 and s390x platforms on Novell’s SLES9 SP3. This release is included with all kernels starting 2.6.5-7.257 and can be downloaded from the SuSE Patch Support Database (PSDB) or by using the YaST Online Update (YOU).

OCFS2 1.2.1 or later is also certified with Oracle 9iR2 and 10g RAC on the x86, x86-64 and IA64 platforms on the above mentioned RHEL4 and SLES9 releases.

Comparison with RAW and EXT 2/3

OCGF2 is a cluster file system, but Ext 2/3 is not, some optimization towards Ext 2/3 will not be applicable to OCGF2. For example, the cache mechanism, which leverages the reading performance of ext, can’t be apply to OCGF2, as what OCGF2 want to build is an simple view of files that can grow and shrink with a clear view across all nodes.

The way OCFS does I/O is the SAME way as IO is done to a raw device inside the kernel.  There is no caching at all when Oracle does an I/O to OCFS, there is no I/O through the Linux buffer cache, there is no OS caching, nothing.  Every read and every write accesses the device.

For writes the nice thing here is that the kernel side of the process will actually be faster, it’s a direct path to disk, no waiting for someone else to go around flushing buffers and coming back.

Therefore:  RAW and OCFS are very comparable in performance.