If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Fenced vs Unfenced Routines

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-11-08, 18:49
db2user db2user is offline
Registered User
 
Join Date: Dec 2002
Posts: 123
Fenced vs Unfenced Routines

What exactly does this mean for stored procedures? Also, how do you specify a routine to be fenced? Thanks!

Last edited by db2user; 09-11-08 at 18:58.
Reply With Quote
  #2 (permalink)  
Old 09-11-08, 21:50
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
A fenced procedure runs outside the DB2 address space and is a little less efficient when communicating with DB2 for that reason. But if there is a problem with a unfenced procedure (such as an address pointer problem) it could cause DB2 to crash.

SQL procedures are always unfenced because you cannot specigy memory addresses in SQL procedure language that would cause a problem (unless there is a bug in DB2 SQL procedure language). C/C++ can be fenced or unfenced, and I believe that Java procedures are always fenced.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #3 (permalink)  
Old 09-12-08, 06:30
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Fenced vs. not fenced (aka trusted) is also applicable to UDFs - with exactly the same arguments that Marcus gave.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #4 (permalink)  
Old 09-12-08, 11:09
db2user db2user is offline
Registered User
 
Join Date: Dec 2002
Posts: 123
thanks guys... is it possible to get this output in the db2diag.log file for any procedures that are not fenced? We have some procedures that are fenced and some that are unfenced. But the time corresponding to the output in the db2diag.log corresponds to issues we had when many customers were calling the sprocs that were unfenced. For some reason, db2sysc goes to 100% when we have too many users logging in and accessing these unfenced sprocs. Could it be a problem of memory when the fenced and unfenced routines are both being called? Also, i have DB2_FMP_COMM_HEAPSZ=7680. Thanks!!

2008-09-04-20.01.06.111359+000 I293174548G495 LEVEL: Severe
PID : 28776 TID : 4096042688 PROC : db2agent (ENERGY1)
INSTANCE: nrg1 NODE : 000 DB : ENERGY1
APPHDL : 0-296 APPID: D1AC9624.KCE0.0960E4200105
FUNCTION: DB2 UDB, routine_infrastructure, sqlerGetFMPIPC, probe:60
RETCODE : ZRC=0x8B0F003B=-1961951173=SQLO_NOMEM_UND
"No memory available in 'Undefined Heap'"
DIA8300C A memory heap error has occurred.

2008-09-04-20.01.06.111676+000 I293175044G448 LEVEL: Severe
PID : 28776 TID : 4096042688 PROC : db2agent (ENERGY1)
INSTANCE: nrg1 NODE : 000 DB : ENERGY1
APPHDL : 0-296 APPID: D1AC9624.KCE0.0960E4200105
FUNCTION: DB2 UDB, routine_infrastructure, sqlerAddFmpToPool, probe:20
MESSAGE : DiagData
DATA #1 : Hexdump, 4 bytes
0xFFE0AE74 : EEFB FFFF ....

2008-09-04-20.01.06.116712+000 I293175493G642 LEVEL: Error
PID : 28776 TID : 4096042688 PROC : db2agent (ENERGY1)
INSTANCE: nrg1 NODE : 000 DB : ENERGY1
APPHDL : 0-296 APPID: D1AC9624.KCE0.0960E4200105
FUNCTION: DB2 UDB, routine_infrastructure, sqlerGetFMPIPC, probe:70
MESSAGE : Insufficient memory available for IPC communication with the db2fmp
process. Use the DB2_FMP_COMM_HEAPSZ registry variable to adjust the
amount of memory available for fenced routines.
DATA #1 : Hexdump, 4 bytes
0xFFE0ABC8 : 0000 0000
Reply With Quote
  #5 (permalink)  
Old 09-12-08, 12:00
db2user db2user is offline
Registered User
 
Join Date: Dec 2002
Posts: 123
Quote:
Originally Posted by Marcus_A
SQL procedures are always unfenced because you cannot specify memory addresses in SQL procedure language that would cause a problem
I understand that SQL sprocs are unfenced always but am confused as to what this phrase means -- 'because you cannot specify memory addresses in SQL procedure language that would cause a problem'

Last edited by db2user; 09-12-08 at 13:05.
Reply With Quote
  #6 (permalink)  
Old 09-12-08, 14:48
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
If your procedure is written in C/C++ or Java, you can do your own memory management and access arbitrary memory regions in your process. With LANGUAGE SQL procedures, this is not possible because the language doesn't give you any handles to mess around in the address space.

Regarding the other question: Each stored procedure invocation needs some memory. If too many concurrent invocations occur, DB2 may need more memory than you have configured. As the last message suggests, you should:
(a) read up on the registry variable DB2_FMP_COMM_HEAPSZ, and
(b) adjust the variable's setting according to your needs

p.s: You may also want to run the DB2 Configuration Advisor to get a baseline configuration. I would guess you haven't done that yet.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #7 (permalink)  
Old 09-12-08, 23:04
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
Quote:
Originally Posted by db2user
I understand that SQL sprocs are unfenced always but am confused as to what this phrase means -- 'because you cannot specify memory addresses in SQL procedure language that would cause a problem'
There is a difference between:
  1. DB2 running out of memory to process the running of a stored procedure or function, and
  2. A stored procedure or funciton stepping on some memory addresses that they should not be and causing the address space to crash (if running unfenced it would crash DB2).

If your SQL stored procedure or function is encountering problems related to memory heaps, forget about the fenced vs. unfenced scenarios because they are not relevant to your problem, except in the event of a bug in DB2. If you think there is a bug in DB2, please contact IBM support.

In general, anytime you get a ZRC error, you should contact IBM support to resolve it.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On