Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: any way to limit the number of iterations of a loop?

Re: any way to limit the number of iterations of a loop?

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: Thu, 25 Feb 1999 02:50:41 GMT
Message-ID: <36dbb81e.17990438@192.86.155.100>


A copy of this was sent to jeff grant <nettmaster_at_my-dejanews.com> (if that email address didn't require changing) On Thu, 25 Feb 1999 02:04:57 GMT, you wrote:

>Hi there-
>
>I was just wondering if anyone knows of a parameter (or something similar) for
>8.0.5 that allows you to set a maximum number of iterations on a loop,
>regardless of the logic in the loop.
>
>Basically, I have a developer that created a 5 line loop that had faulty
>logic (basically, while(true) loop;) and ran for about 6 hours before it
>could be shut down, sucking about 80% of the CPU in the process.
>

no there is not... but you can use profiles on your developers to limit the amount of various resources they can use. for example (this modifies the DEFAULT resource, might want to create a developer profile and assign it to them)

SQL> select * from dba_profiles;

PROFILE                        RESOURCE_NAME                    LIMIT
------------------------------ -------------------------------- 
DEFAULT                        COMPOSITE_LIMIT                  UNLIMITED
DEFAULT                        SESSIONS_PER_USER                UNLIMITED
DEFAULT                        CPU_PER_SESSION                  UNLIMITED
DEFAULT                        CPU_PER_CALL                     UNLIMITED
DEFAULT                        LOGICAL_READS_PER_SESSION        UNLIMITED
DEFAULT                        LOGICAL_READS_PER_CALL           UNLIMITED
DEFAULT                        IDLE_TIME                        UNLIMITED
DEFAULT                        CONNECT_TIME                     UNLIMITED
DEFAULT                        PRIVATE_SGA                      UNLIMITED

9 rows selected.

SQL> declare
  2 n number;
  3 begin

  4     for i in 1 .. 100000 loop
  5       n := i*2+5;
  6     end loop;

  7 end;
  8 /

PL/SQL procedure successfully completed.

SQL> save a repl
Wrote file a

SQL> alter profile default limit cpu_per_session 1; Profile altered.

SQL> connect tkyte/tkyte
Connected.
SQL> @a
declare
*
ERROR at line 1:
ORA-02392: exceeded session limit on CPU usage, you are being logged off

so, when I exceeded the default -- boom, i'm gone..

>Anyone have a way of dealing with something like this?
>

i had a programmer once write a small program (to see what would happen) that looked like:

while(1) fork();

try killing that one :)

>
>---------------------------------------------
>jeff grant, it manager, nettwerk productions
>vancouver, bc, canada
>http://www.nettwerk.com http://www.nettweb.com
>
>-----------== Posted via Deja News, The Discussion Network ==----------
>http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
 

Thomas Kyte
tkyte_at_us.oracle.com
Oracle Service Industries
Reston, VA USA

--
http://govt.us.oracle.com/ -- downloadable utilities  



Opinions are mine and do not necessarily reflect those of Oracle Corporation Received on Wed Feb 24 1999 - 20:50:41 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US