Daily Roundup of News, Tips and Tricks for 2010-02-09

  • A list of Oracle Strategic acquisitions by category.
  • Documentation of Oracle wait groups and their wait events.
  • Oracle is preparing a public-relations onslaught, intended to change the perception of Oracle as cloud critic.
  • Oracle has agreed to acquire AmberPoint, a leader in Service-Oriented Architecture (SOA) Management.
  • This Security Alert addresses security issue CVE-2010-0073, a vulnerability in the Node Manager component of Oracle WebLogic Server. This vulnerability may be remotely exploitable without authentication, i.e. it may be exploited over a network without the need for a username and password. A knowledgeable and malicious remote user can exploit this vulnerability which can result in impacting the availability, integrity and confidentiality of the targeted system.
  • Can you trust the leading open-source database engines, PostgreSQL and MySQL, to deliver the performance and features that the Oracles, SQL Servers, and DB2s of the world do? Not just yet, but they could offer enough to meet your needs. Find out how they stack up against each other, as well as against the commercial alternatives.

Related articles:

what is the type of NULL

I was a bit surprised to see a VARCHAR2(0) column in my schema


select column_name, data_type, data_length 
from user_tab_columns 
where table_name='V';
COLUMN_NAME     DATA_TYPE            DATA_LENGTH
--------------- -------------------- -----------
X               VARCHAR2                       0

What’s this datatype? It is the datatype of NULL !!!

SQL> create or replace view v as select null x from dual
View created.
SQL> desc v
VIEW v
 Name              Null?    Type        
 ----------------- -------- ------------
 X                          VARCHAR2(0) 

Oracle Wait Event reference

Kyle Hailey has started putting together a much needed Oracle wait event reference.

You can access it here.

By the way, Oracle documentation also has a wait event reference section, it has more events, but it’s less detailed…

I have plans to go deep into some wait events and cover some less common ones in tech.E2SN too… in the future ;-)

Share/Bookmark

APEX@Your Oracle Usergroup

Just a quick note to say I often get asked if I can present at a Oracle usergroup meetings.

The answer is usually ‘yes I’d love to’, since -

1) I love to talk about and promote APEX
2) I love to travel

So, if you have an Oracle usergroup and you’re interested in promoting Oracle Application Express or looking for an APEX speaker, please feel free to drop me an email (john@sumneva.com) and hopefully we can arrange something.

APEX at OBUG Connect 2010

In November last year I blogged about a new initiative to launch an APEX SIG in the Benelux.
The first results of that you'll see at the biggest Oracle User Group event in the Benelux, called OBUG Benelux Connect. This year it's held in Arnhem, the Netherlands on Tuesday March 23. Every year it changes location between Belgium and the Netherlands.


Where last year there were zero APEX sessions, this year Oracle Application Express became a focus area! There are three APEX sessions planned.

11.30 - 12.15 From subsidy request to payment: fast and flexible with Oracle APEX by Erik van Dongen and Arlette Koeijers is a case study of an app at the Ministry of Agriculture.

14.30 - 15.15 Defending the shores with Oracle Application Express by Arie in't Veld and Bart Meijer is another case study where previous Excel was used and which got replaced by APEX and BI Publisher to print PDF's.

15.45 - 16.30 APEX 4.0 by Dimitri Gielis. I'll speak about the biggest differences in developing in APEX 4.0 compared to earlier versions. Of course I'll demo the coolest APEX 4.0 new features!

You find all information in the program magazine of OBUG Connect 2010 (pdf) or online on the OBUG site.

Hope to see you there!

Advert: Symposium Countdown

I submitted my slides last Friday so the Hotsos Symposium countdown has really started now - I'll be presenting in just under 4 weeks time. I'm looking forward to it even more than I was for a couple of reasons.

1) I noticed from Kerry Osborne's blog post that he's now doing two presentations. I was looking forward to seeing Kerry present anyway and it looks like his second presentation is about some of the AWR scripts that he's written and I find myself returning to all the time and passing on to other on-site.

2) The good folk at Hotsos took pity on me and my sick server, which has been throwing out mysterious I/O errors intermittently over the past few months while I've been trying to test Parallel Query in 11.2. In the end, I just felt that I didn't have enough decent material for me to feel comfortable presenting it so they're letting me do my Pictures presentation instead ;-) I've only ever done it once in the U.S. and there were about 10 people in the room, most of whom I knew (!), so it's still pretty new and I'm enjoying including the 11.2 stuff too. However, I'm not prepared to suffer flaky demos any more, as I did at UKOUG, so have just ordered a Dell XPS16 with one of those funky i7 CPUs and an SSD drive. Hopefully it will make things a lot smoother! It should also facilitate the 11gR2 Parallel experimentation - I don't need real-world performance or DOPs, just enough to illustrate features without my laptop grinding to a halt! So, the Parallel stuff isn't done - I'll be doing that at MOTS - but delayed for now.

As usual, I'm really looking forward to this one. I was having beers with a couple of the best techies at work the other night, neither of whom are completely convinced about the value and technical depth of conferences and I told them this is the one they should think about going to. What I forgot to mention was the number of new friends I met at Hotsos. If anyone is thinking of 'cliques', these were people who I wouldn't have known from Adam but the fact that Hotsos is small (500 attendees) and everyone who is there has a keen interest in Oracle performance means that you're likely to meet plenty of like-minded people.

Oh, and where are the technical posts? Well I interrupted the first of a possibly long series of posts on optimiser stats to write this. Those technical posts take a little longer, just getting the examples right, but things should start looking up soon. With my low posting frequency over the past few months, I'm not exactly short of things to write about.

Eat Food. Not too much. Mostly plants.

On January 13, we buried my father, Sheldon Feuerstein. On January 25, we buried my sister, Laurie Feuerstein Walsh. It has been a horrible couple of months (December and January). I can only hope that the rest of 2010 is better for all of us.

I feel very strongly that both Dad and Laurie had health problems contributing to their deaths that came from the foods they ate and the toxic environments in which they, we all, lived (any urban environment saturates us with toxins). Those same foods are likely causing problems for the rest of us, too. I have lately been struck by how ridiculous it is that food has become such a complicated and treacherous affair, that we seem to need nutritionists and scientists and politicians to decide what is good for us to eat. Isn't that strange? Humans have been finding, growing, preparing and eating food for thousands of years - and surviving quite well, thank you - without all this "assistance." And in the US, where the nutritionists reign supreme, we are getting fatter and sicker with each year. Something is so deeply wrong with this picture.

Fortunately, I think the solution to this problem is very simple: "Eat Food. Not too much. Mostly plants."

That is the mantra of a man named Michael Pollan. He has just published a book called Food Rules, which I urge you to purchase and read immediately (only $5 from Amazon!).  This small, very accessible book offers simple, practical advice regarding food that can help all of us regain control of our bodies and our health.

Here is what I have decided so far from reading this book: I am going to stop purchasing packed, processed food products (not the same as food) as much as possible. No more Ritz crackers (absolutely yummy with PBJ), no more ramen noodles (I love those with a generous helping of sauteed brussel sprouts).

NO MORE HIGH FRUCTOSE CORN SYRUP at all. I will check every package. I am now convinced more than ever that that stuff is a poison (or at the very least a drug) that operates at a very deep level on our physiology, making us fat and sick.

If you are sick or you have a family member who is sick; if you are affected by any of the four "Western diseases" (obesity, high blood pressure, diabetes or cancer); if you simply don't feel all that great (low energy, acid reflux, etc.) - then please, please, take a serious look at a serious change to your diet. It could make all the difference.

Data Warehouse Fault Tolerance Part 1: Resuming

In the introduction to this series of posts, I spoke briefly about data warehouse fault tolerance and the unique challenges resulting from high data volumes combined the batch load window required to create them. I then defined the goal: a layered approach allowing simple errors to be caught early before they turn in to serious conditions.

Resuming is the ability to continue effortlessly after an error. The important thing is that there should be no aftermath from the error: our process should pause gracefully until the error is corrected. The Oracle Database has offered out of the box functionality for resuming since version 9i in the form of Resumable Space Allocation. Resumable operations are supported for SELECT queries, DML and DDL, and can be enabled at either the system or the session level. To enable at the system level, the RESUMABLE_TIMEOUT database parameter should have a non-zero value.

SQL> alter system set resumable_timeout=3600;

System altered.

SQL>

To enable resumable operations at the session level, the statement follows this basic syntax, with the TIMEOUT and NAME clauses being optional:

ALTER SESSION ENABLE RESUMABLE <TIMEOUT n> <NAME string>;

The TIMEOUT value is specified in seconds, and if omitted, the default value of 7200 is used, or 2 hours. The NAME clause gives the resumable session a user-friendly name for when we are monitoring for resumable sessions (as we will see later) to see which of our processes is suspended. Enabling resumable operations for the session level requires that the RESUMABLE permission has been granted:

SQL> grant resumable to stewart;

Grant succeeded.

SQL>

Resumable operations can also be enabled with the Oracle utilities… such as SQL-Loader, Export/Import and Datapump. The command-line parameters RESUMABLE, RESUMABLE_NAME and RESUMABLE_TIMEOUT exist to mimic the functionality mentioned above.

Now for a demonstration. I’ll create a situation that is ripe for a space allocation error: I’ll put an empty copy of the SALES fact table from the SH schema in a tablespace with only 250K of space:

SQL> create tablespace target datafile '/oracle/oradata/bidw1/target01.dbf' size 250K;

Tablespace created.

SQL> create table target.sales tablespace target as select * from sh.sales where 1=0;

Table created.

SQL>

Now I’ll load some records into the table, which should cause it to suspend. To prepare my session, I need to enable resumable operations. Since I always instrument my code, I’ll register my process with the database. After that, I have an easy way to guarantee consistency when referring to processes. Now, I can use the registered name for my resumable session as well:

SQL> exec dbms_application_info.set_module('SALES fact load','insert some rows');

PL/SQL procedure successfully completed.

SQL>
SQL> DECLARE
  2     l_module VARCHAR2(48) := sys_context('USERENV','MODULE');
  3  BEGIN
  4     EXECUTE IMMEDIATE
  5     'alter session enable resumable timeout 18000 name '''||l_module||'''';
  6  END;
  7  /

PL/SQL procedure successfully completed.

SQL>

I start loading the records in hopes of a suspended session:

SQL> insert into target.sales select * from sh.sales;

So now, I open up another session, and I start another transaction against the TARGET.SALES table, just to pile on the TARGET tablespace:

SQL> exec dbms_application_info.set_module('SALES fact load2','insert more rows');

PL/SQL procedure successfully completed.

SQL>
SQL> DECLARE
  2     l_module VARCHAR2(48) := sys_context('USERENV','MODULE');
  3  BEGIN
  4     EXECUTE IMMEDIATE
  5     'alter session enable resumable timeout 18000 name '''||l_module||'''';
  6  END;
  7  /

PL/SQL procedure successfully completed.

SQL> insert into target.sales select * from sh.sales;

I’ll have a look in the DBA_RESUMABLE view (there is also a USER_RESUMABLE version) for my suspended sessions. Even though I could get all the following information with a single SQL statement, I broke it up for better visibility on the blog:

SQL> select name, start_time, suspend_time, status from dba_resumable;

NAME              | START_TIME           | SUSPEND_TIME         | STATUS
----------------- | -------------------- | -------------------- | ------------
SALES fact load2  | 02/06/10 10:33:33    | 02/06/10 10:33:33    | SUSPENDED
SALES fact load   | 02/06/10 10:29:03    | 02/06/10 10:29:03    | SUSPENDED

2 rows selected.

Elapsed: 00:00:00.07
SQL> select name, sql_text from dba_resumable;

NAME              | SQL_TEXT
----------------- | -----------------------------------------------
SALES fact load2  | insert into target.sales select * from sh.sales
SALES fact load   | insert into target.sales select * from sh.sales

2 rows selected.

SQL> select name, error_msg from dba_resumable;

NAME              | ERROR_MSG
----------------- | ------------------------------------------------------------------------
SALES fact load2  | ORA-01653: unable to extend table TARGET.SALES by 8 in tablespace TARGET
SALES fact load   | ORA-01653: unable to extend table TARGET.SALES by 8 in tablespace TARGET

2 rows selected.

SQL>

The Oracle Database also publishes server alerts concerning suspended transactions using the Server-Generated Alerts infrastructure. This infrastructure uses the AWR toolset, the server package DBMS_SERVER_ALERT for getting and setting metric threshholds, and the queue table ALERT_QUE to hold alerts that have been published from AWR. Custom processes could be written to mine ALERT_QUE for these alerts, but the easiest way to configure and view server alerts is using Oracle Enterprise Manager (OEM). On the Alerts section of the main OEM page, we can see three different alerts generated by the Oracle Database:

all alerts.png

If we click on the “Session Suspended” link, we can see the multiple alerts generated in this category:

suspend alerts.png

Another alert generated indirectly by the suspended transaction is the “Configuration” class event caused by our session “waiting” to proceed. The Oracle wait event interface can show us information about the suspend waits on the system:

SQL> SELECT event,
  2         SUM(time_waited) time_waited,
  3         SUM(total_waits) total_waits,
  4         AVG(average_wait) average_wait
  5    FROM gv$session_event
  6   WHERE lower(event) LIKE '%suspend%'
  7   GROUP BY event
  8   ORDER BY time_waited ASC
  9  /

EVENT                                          | TIME_WAITED | TOTAL_WAITS | AVERAGE_WAIT
---------------------------------------------- | ----------- | ----------- | ------------
statement suspended, wait error to be cleared  |      305373 |        1377 |       221.78

1 row selected.

SQL>

To free up the space issue, I’ll enable autoextend on the TARGET tablespace. Then, I’ll take a look and see if anything has changed:

SQL> alter database datafile '/oracle/oradata/bidw1/target01.dbf'
  2  autoextend on next 10M maxsize 1000M;

Database altered.

SQL> select status, resume_time, name from dba_resumable;

STATUS       | RESUME_TIME          | NAME
------------ | -------------------- | -----------------
NORMAL       | 02/06/10 10:56:49    | SALES fact load2
NORMAL       | 02/06/10 10:56:49    | SALES fact load

2 rows selected.

SQL>

The Resumable Space Allocation features includes the AFTER SUSPEND trigger, which allows the specification of a system-wide trigger that will fire whenever a transaction is suspended. The typical use for this functionality is alerting as suspended operations don’t write anything to the alert log.

UPDATE: I made a mistake here… suspended transactions do in fact cause entries in the alert log, and so does the RESUME process detailed below.

There are some features in the DBMS_RESUMABLE package that may make sense when writing an AFTER SUSPEND trigger:

SQL> desc dbms_resumable
PROCEDURE ABORT
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 SESSIONID                      NUMBER                  IN
FUNCTION GET_SESSION_TIMEOUT RETURNS NUMBER
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 SESSIONID                      NUMBER                  IN
FUNCTION GET_TIMEOUT RETURNS NUMBER
PROCEDURE SET_SESSION_TIMEOUT
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 SESSIONID                      NUMBER                  IN
 TIMEOUT                        NUMBER                  IN
PROCEDURE SET_TIMEOUT
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 TIMEOUT                        NUMBER                  IN
FUNCTION SPACE_ERROR_INFO RETURNS BOOLEAN
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 ERROR_TYPE                     VARCHAR2                OUT
 OBJECT_TYPE                    VARCHAR2                OUT
 OBJECT_OWNER                   VARCHAR2                OUT
 TABLE_SPACE_NAME               VARCHAR2                OUT
 OBJECT_NAME                    VARCHAR2                OUT
 SUB_OBJECT_NAME                VARCHAR2                OUT

SQL>

This package adds functionality for writing custom processes in the AFTER SUSPEND trigger. The SPACE_ERROR_INFO function returns specifics about the table and tablespace affected by the space error. A series of checks could be coded enabling specific actions depending on which objects were affected. A suspended process can be ended prematurely with the ABORT procedure, or more time can be added using the SET_TIMEOUT procedure. I actually had one client explain how she had written an AFTER SUSPEND trigger that compiled information about the tablespace affected so that an “ALTER DATABASE… RESIZE…” command could be issued to add more space to the affected datafile. I didn’t have the heart to tell her that she had basically written a feature that already existed in the database: AUTOEXTEND.

So what are the best practices to take away from this? Quite simply… all ETL mappings and flows, as well as database maintenance processes, should use Resumable Space Allocation, preferably using the NAME clause in conjunction with DBMS_APPLICATION_INFO. Setting a RESUMABLE_TIMEOUT value at the system level can be scary, because a single suspended transaction could cause locks that reverberate all the way through the system. But is this really a concern in a BI/DW environment? Are there any processes in our batch load window or with any of our operational maintenance processes that we wouldn’t want to enable for resumable operations, no matter how many processes back up waiting for them to complete? It could spell bad news if we used any kind of synchronous replication technology to move data to the DW instance, but short of that, I can’t think of any. Please let me know if you have alternative viewpoints.

I’ve never found much reason to use the AFTER SUSPEND trigger though. Data warehouses should have production-type monitoring running already, just like other production systems. OEM is more than satisfactory for basic monitoring and alerting, and with the Server-Generated Alerts introduced in 10g, forms a complete product for Oracle environments. But regardless of which monitoring solution is used, it should be able to issue simple queries against the database and alert based on the results of those queries. A select against the DBA_RESUMABLE table provides all the information required to send out an alert, and with features such as AUTOEXTEND, I just can’t see a requirement for the ability to issue procedural code because a transaction is suspended.

UPDATE: as pointed out above, since suspended transactions do in fact show up in the alert log, this is good news for integrating Resumable Space Allocation into an existing environment. Assuming that there’s proper alert log monitoring with paging functionality already in place, implementing resumable operations can simply use that infrastructure already in place.

Keep your eyes open for the next of the “Three R’s” in BI/DW fault tolerance: Restarting.

Daily Roundup of News, Tips and Tricks for 2010-02-08

  • On Friday, Ken Jacobs announced his resignation from Oracle to key members of the MySQL team via e-mail. Jacobs, a 28-year Oracle veteran and one of its first 20 hires, has been Oracle's liaison with the MySQL community for the past several years, ever since Oracle acquired the popular MySQL storage engine, InnoDB.
  • SAP CEO Leo Apotheker resigned on Feb. 7 after he and the SAP Supervisory Board "reached a mutual agreement" not to extend Apotheker’s contract as a member of the SAP Executive Board, SAP named Bill McDermott, head of SAP’s field organization and Jim Hagermann Snabe, head of product development as co-CEOs replacing Apotheker as sole CEO.
  • Oracle’s Larry Ellison threw down the gauntlet recently when he made claims about the superiority of Oracle over DB2. IBM has, of course, responded. Here are the Oracle claims and the IBM rebuttals.
  • It is an interesting case of coincidental timing that within a week of the Oracle Sun deal being finalised by the EU1 that the Blackhat conference in DC should publish David Litchfield’s research for NGS Software 2, on how to escalate privilege using the Java functionality built into the Oracle DB 3. David’s research is not patched yet so would normally have only been made privy to the Administrators at Oracle’s SecAlert, but it has been made “Public” so it is now risk mitigation time. Thankfully these Java related Oracle vulnerabilities have been discussed privately for a number of months beforehand, thus giving the Author time to fix them with a provably low risk of affecting other Oracle functionality. In the absence of a patch from Oracle this paper provides information on how to fix the Java related vulnerabilities in both 10g and 11g which were detailed in David’s Blackhat presentation on February 2nd 2010.
  • This is a somewhat complicated example that builds a couple of sample tables, uses a SQL statement with the Oracle analytic function LEAD submitted through ADO in an Excel macro, and then presents the information on an Excel worksheet. When the user clicks one of three buttons on the Excel worksheet, an Excel macro executes that then build charts using disconnected row sources – a disconnected ADO recordset is used to sort the data categories before pushing that data into the charts that are built on the fly.

Related articles:

Shrink Tablespace

Here’s an example of a theme that appears on the OTN datbase forum from time to time (I haven’t included a link to it because it’s just one example of many similar questions): “I have a user tablespace alocated for 3-4 schemas. As I urgently needed space on hard disk I had to remove one of [...]