473,385 Members | 1,772 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

DB2 UDF as module (was:DB2 UDF timeout)

Hello,

[this is the followup of the "DB2 UDF timeout"
thead - i've decided to replace the subject
though because of the new topic]
A note: by thread i always mean the worker thread on which SP is
running on.

ok, if there is no UDF execution timeout thing what about the following
theme:

Treat UDF as module ie once it is started it enters potentailly
endless loop and waits for new db oriented "tasks" via some system
wait object like semaphore, gets input for job via, for example, shared
mem and
returns the result via shared mem too.
>From the CLI view the UDF is always running while in reality
the UDF's thead will enter wait state waiting for new work task from
time to time.

So will db2 will be still healthy with this theme?

another question - on whole db2 engine shutdown will the current
UDF's statement against db will be aborted with error code like
QUERY_ABORTED - to give the chance for the dll to free allocated
resources to unload cleanly?

If yes, then why not to extend a "SQLUDF_DBINFO" context struct that is
passed to UDF routine - it will be great to add a volatile variable to
it say:

volatile int is_closing;

which becomes "1" when the db2 engine enters some sort of "closing"
state for at least several seconds for all aware UDF to end.
regards, dmitry

Sep 11 '06 #1
1 1640
dm***********@mail.ru wrote:
A note: by thread i always mean the worker thread on which SP is
running on.
You shouldn't consider it as a "thread". DB2 may execute an external
routine (UDF or SP) in the main thread, i.e. there don't have to be other
threads in the same process. Or do you mean "sessions"?
ok, if there is no UDF execution timeout thing what about the following
theme:

Treat UDF as module ie once it is started it enters potentailly
endless loop and waits for new db oriented "tasks" via some system
wait object like semaphore, gets input for job via, for example, shared
mem and
returns the result via shared mem too.
That sounds like a typical daemon process. I would start only it through a
UDF but not have it run inside a UDF.
>>From the CLI view the UDF is always running while in reality
the UDF's thead will enter wait state waiting for new work task from
time to time.
From DB2's point of view, the UDF _is_ always running. It doesn't matter if
the UDF sleeps in between. In fact, any UDF is forced off the processor
when the current time slice expires. So you have a forced sleep. What
does matter is that DB2 doesn't get the control back from the UDF.
So will db2 will be still healthy with this theme?
I'm not sure. One issue I see with that, however: In order to invoke the
function, DB2 will have to
- an open session running
- a transaction initiated
- do some lookups on the catalog for function resolution

All this allocates resources that are never freed since you don't intend to
regularly terminate the UDFs processing.
another question - on whole db2 engine shutdown will the current
UDF's statement against db will be aborted with error code like
QUERY_ABORTED - to give the chance for the dll to free allocated
resources to unload cleanly?
This is not only relevant on engine shutdown. A simple FORCE will already
have to be dealt with.

The control is currently inside the UDF. DB2 doesn't go out of its way to
somehow send information to the UDF the way you describe.

The assumption is that DB2 can unload the library safely with "dlclose".
(The library is loaded with "dlopen".) DB2 keeps track of loaded libraries
and only unloads them if they are not in use. So that means, a UDF should
always properly cleanup after itself on each call or in the last call (in
FINAL CALL has been used).
If yes, then why not to extend a "SQLUDF_DBINFO" context struct that is
passed to UDF routine - it will be great to add a volatile variable to
it say:

volatile int is_closing;

which becomes "1" when the db2 engine enters some sort of "closing"
state for at least several seconds for all aware UDF to end.
That would be possible.

But the real question is: what would that be good for? What exactly do you
want to do? Maybe there are other solutions available already?

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Sep 11 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: cab0san | last post by:
I downloaded the DB2 runtime client, but the Client Base support and the TCP protocol do not install. I re-run the setup select them to run from disk, and they still show as not installed. What am...
11
by: Mark A | last post by:
Here is Mark Townsend's (Oracle Product Manager) explanation and justification for posting in the DB2 newsgroup, as posted on the Oracle newsgroup, and my response: "Mark Townsend"...
6
by: chrisg | last post by:
I have installed (what I thought was) DB2 7.2 FP5 (as my starting point, it was 7.2 with FP5 applied) on my AIX 4.3.3 boxes. This is what I get. # lslpp -L | grep db2 db2_07_01.cj ...
7
by: lopezadmin | last post by:
Announcement! Best DB2 Articles was started as a means to collect and share information between IT Professionals who work with DB2 on any platform and in any capacity. I have been working with...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.