Showing posts with label ORA-21779. Show all posts
Showing posts with label ORA-21779. Show all posts

Friday, July 13, 2007

ORA-21779, the final revenge?

Yes, it's the third time i have to talk about this awful, elusive, erratic, annoying oracle error.

But there are chances that we are finally approaching the end of this nightmare.

I was testing a new, top-secret ;-) function that uses REGEXP_REPLACE as part of his logic and is called several times within a report region of an Oracle Application Express page and almost immediately i began hitting this haunting problem.

ORA-21779: Duration not active

I found myself screaming: "NO! NOT AGAIN!".

And this time it wasn't occurring on my Windows machine but on a full fledged Solaris server.

So, i contacted my friend John Scott who was fairly surprised to hear about that and together we immediately set out in pursuit of a solution.

The worse thing about this error is in that it's an intermittent one.
It may appear three times in a row then it can disappear for two times, then once again and so on, without any meaningful pattern.

At any rate, after a huge amount of try-this and try-that, John had an excellent intuition:

"It could have to do with the session character set".

He based this assumption on the fact that he experienced the problem only when he was looking at the page in the Italian version, but apparently the error didn't occur when the page was in English.

Given the fact that Apex, as part of its globalization logic, alters some sessions parameters depending on the current language setting, whose detection method is defined in the application attributes, it is perfectly possible that, by doing so, it's affecting the way REGEXP_REPLACE works when it is embedded in an Apex report.

With this theory in mind, i initially created two page processes, one occurring Before Regions and the other one occurring After Regions.
The former saves the current NLS_LANGUAGE into an application item and temporarily sets NLS_LANGUAGE='AMERICAN', the latter sets NLS_LANGUAGE back to its previous value.

bug fix part#1 (to be run right before the report):

begin
select value
into :SAVED_NLS_LANGUAGE
from nls_session_parameters
where parameter = 'NLS_LANGUAGE';

execute immediate 'ALTER SESSION SET NLS_LANGUAGE=''AMERICAN''';
end;

bug fix part #2 (to be run right after the report)

begin
execute immediate 'ALTER SESSION SET NLS_LANGUAGE='
|| chr(39) || :SAVED_NLS_LANGUAGE || chr(39);
end;


And you know what?
ORA-21779 is gone!
Since i implemented the ALTER SESSION fix, i haven't seen this error any more.

At this point i started refining the bug fix, because i didn't want to run these PL/SQL snippets before and after each and every region, but just before and after the offending one, so i converted the page processes into two special PL/SQL based page regions, surrounding the main report region.
And the report works fine.

Although we apparently managed to get rid of the problem, we couldn't precisely identify the root cause. The attempts to reproduce the error in a simpler scenario have failed, so it's not just a matter of setting NLS_LANGUAGE='ITALIAN' and call REGEXP_REPLACE, there must be something else going on behind the scene.

I am rather sure that it's a combination of factors:
  1. the use of REGEXP_REPLACE;
  2. the NLS_LANGUAGE setting;
  3. the function call to REGEXP_REPLACE inside a report region, as part of an iterative process where a CLOB object is eventually returned perhaps?
  4. some other component we don't even suspect of?
The bad aspect with bugs like this is in that it makes really hard to submit a TAR request because of the complex setup required to reproduce the problem and without a minimal set of steps showing the problem, there are few chances to draw the attention of Oracle Support and get it fixed.

See message translations for ORA-21779 and search additional resources.

Friday, November 24, 2006

ORA-21779 reloaded

I am getting no more ORA-21779 lately.
I am wondering if patch 10.1.0.5 did work in the end for my regexp_replace problem.
Definitely a weird case.

UPDATED July 13, 2007
if you are getting this error in an Oracle Application Express page, try out this workaround.



ORA-21779: durata non attiva
ORA-21779: duración no activa
ORA-21779: durada inactiva
ORA-21779: durée dépassée
ORA-21779: Dauer nicht aktiv
ORA-21779: διάρκεια μη ενεργή
ORA-21779: varighed ikke aktiv
ORA-21779: varaktigheten är inte aktiv
ORA-21779: varighet ikke aktiv
ORA-21779: kesto ei aktiivinen
ORA-21779: az időtartam nem érvényes
ORA-21779: durata nu este activă
ORA-21779: Tijdsduur is niet actief.
ORA-21779: duração não está ativa
ORA-21779: duração não activa
ORA-21779: период не активный
ORA-21779: trvání není aktivní
ORA-21779: trvanie nie je aktívne
ORA-21779: nie uaktywniono czasu trwania
ORA-21779: süre etkin değil

Monday, July 31, 2006

ORA-21779 the brain teaser

Amongst my favourite oracle 10G enhancements there is the support for regular expressions.
There is a whole bunch of functions to deal with strings using these powerful pattern matching descriptors so i decided to use them for implementing a procedure that unscrambles search engine URLs in pursuit of the search keywords that led a user to my site.

So, i set out and wrote this wonderful web search URL decoder for the most popular engines like Google and Yahoo and installed it on my development box, just to find out minutes later that, at times, i was getting a strange error called ORA-21779: Duration not active.

The short error description wasn't very helpful, what kind of duration is it talking about?!?
Don't panic, let's see first what the Error Messages manual for version 10.1 says about it.

Cause: User is trying to use a duration that has been terminated
Action: User should avoid performing such operation.

I don't know the rest of you guys, but i'd love to know the "backstage" of the birth of this message. I get this fancy picture in my mind of two tired oracle techies working late in an office where everyone else is at home and sleeping and one screams at the colleague sitting at the other end of a big open space room:

- JOE! What was that error you got this morning?
- ...ion not active! (very weak)
- What?
- ...ion NOT ACTIVE! (somewhat louder)
- HUH?!?
- &$%!!
- (long silence)... and how do you fix it?
- Just don't do it!
- (long silence)

At any rate, back to my problem, it took me a while to figure out that the error was raised by function regexp_replace, for two reasons:

#1 the error was not returned every time i executed the query even against the same inputs.
#2 the function is contained in a so-called "process" inside a page definition of Oracle Apex (Application Express 2.0) , so, at first i thought it was returned by the underlying query of the report being displayed, not by the after submit process.

So, in the end, i commented out the function call and the error stopped occurring.
Said that, i turned up to oracle metalink in search of more descriptive explanations of the problem but i found just one note mentioning regexp functions called inside "pipelined functions".
I also found another note (or was it the same?) suggesting that patch 10.1.0.5 could fix the problem, so i installed the patch too, with little success regarding the point, but introducing the ORA-12640 problem i related in a previous post.
It was not my lucky day, definitely.

After several attempts to isolate the real cause of the problem however, i found out that the error can happen even without nesting regexp_replace inside pipeline functions, but still i cannot reproduce this behaviour sistematically, there is some erraticism in it.
To add more to the picture, this seems to be a Windows only problem.
I could not manage to reproduce it on Solaris, which is good on the other hand because it's my target production environment.
I also left a message in the metalink forum, but nobody has replied up to date.

So, at the end of the day, the function in my development box is still haunted by these infrequent ORA-21779 errors and i don't dare to install the new functionality in a production environment even if, so far, all the tests have returned positive results.

Any suggestions?

PS: UPDATED July 13, 2007
if you are getting this error in an Oracle Application Express page, try out this workaround.

yes you can!

Two great ways to help us out with a minimal effort. Click on the Google Plus +1 button above or...
We appreciate your support!

latest articles