-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ORA-28112: failed to execute policy function #233
Comments
Well, I think I've manage to create a test that reproduces it completely and ends up with: which kinda confirms my hunch regarding dangling cursors.
|
I know this problem (cursors aren't closed everytime), but couldn't find
the solution, yet.
kogan69 <[email protected]> ezt írta (időpont: 2017. nov. 14., K,
16:47):
… Well, I think I've manage to create a test that reproduces it completely
and ends up with:
panic: Stmt.exeC Env.ociError ORA-00604: error occurred at recursive SQL
level 1
ORA-01000: maximum open cursors exceeded
ORA-01000: maximum open cursors exceeded
ORA-06512: at "PARAGONEX.SP_LOB_TEST", line 4
which kinda confirms my hunch regarding dangling cursors.
Here's the test:
package main
import (
_ "gopkg.in/rana/ora.v4"
"fmt"
"gopkg.in/rana/ora.v4"
)
func main() {
var createTableQry string = `
begin
begin
execute immediate 'drop table lob_test';
exception
when others then
null;
end;
execute immediate 'create table lob_test (c clob)';
execute immediate 'insert into lob_test values (''Hello'')';
execute immediate 'insert into lob_test values (''world!'')';
commit;
exception
when others then
null;
end;`
dbConnectionString := ***@***.***:1521/DB"
SessionPool, err := ora.NewPool(dbConnectionString, 32)
session, err := SessionPool.Get()
if err != nil {
panic(err)
}
_, err = session.PrepAndExe(createTableQry)
if err != nil {
panic(err)
}
var createSpQry string = `
CREATE OR REPLACE PROCEDURE sp_lob_test(o_cur_lob OUT SYS_REFCURSOR,
o_cur_date OUT SYS_REFCURSOR) AS
BEGIN
OPEN o_cur_lob FOR
SELECT * FROM lob_test;
OPEN o_cur_date FOR
select sysdate from dual;
end sp_lob_test;`
_, err = session.PrepAndExe(createSpQry)
if err != nil {
panic(err)
}
SessionPool.Put(session)
qry := "call sp_lob_test(:o_cur_lob, :o_cur_date)"
for i := 0; i < 1000000; i++ {
session, err := SessionPool.Get()
if err != nil {
panic(err)
}
stmt, err := session.Prep(qry)
if err != nil {
panic(err)
}
c1 := &ora.Rset{}
c2 := &ora.Rset{}
_, err = stmt.Exe(c1, c2)
if err != nil {
panic(err)
}
fmt.Printf("iteration #%d\n", i)
fmt.Println(c1)
fmt.Println(c2)
stmt.Close()
SessionPool.Put(session)
}
}
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#233 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAPoSm7pgFnnC5T1ij1CAGVD0ii6IBWOks5s2bYrgaJpZM4QdMF5>
.
|
What’s the problem, exactly? May be I can suggest my two cents, man?
Cheers,
LK
… On Nov 14, 2017, at 6:09 PM, Tamás Gulácsi ***@***.***> wrote:
I know this problem (cursors aren't closed everytime), but couldn't find
the solution, yet.
kogan69 ***@***.***> ezt írta (időpont: 2017. nov. 14., K,
16:47):
> Well, I think I've manage to create a test that reproduces it completely
> and ends up with:
> panic: Stmt.exeC Env.ociError ORA-00604: error occurred at recursive SQL
> level 1
> ORA-01000: maximum open cursors exceeded
> ORA-01000: maximum open cursors exceeded
> ORA-06512: at "PARAGONEX.SP_LOB_TEST", line 4
>
> which kinda confirms my hunch regarding dangling cursors.
> Here's the test:
>
> package main
>
> import (
> _ "gopkg.in/rana/ora.v4"
> "fmt"
> "gopkg.in/rana/ora.v4"
> )
>
> func main() {
>
> var createTableQry string = `
> begin
> begin
> execute immediate 'drop table lob_test';
> exception
> when others then
> null;
> end;
> execute immediate 'create table lob_test (c clob)';
> execute immediate 'insert into lob_test values (''Hello'')';
> execute immediate 'insert into lob_test values (''world!'')';
> commit;
> exception
> when others then
> null;
> end;`
>
> dbConnectionString := ***@***.***:1521/DB"
> SessionPool, err := ora.NewPool(dbConnectionString, 32)
>
> session, err := SessionPool.Get()
> if err != nil {
> panic(err)
> }
>
> _, err = session.PrepAndExe(createTableQry)
>
> if err != nil {
> panic(err)
> }
>
> var createSpQry string = `
> CREATE OR REPLACE PROCEDURE sp_lob_test(o_cur_lob OUT SYS_REFCURSOR,
> o_cur_date OUT SYS_REFCURSOR) AS
> BEGIN
> OPEN o_cur_lob FOR
> SELECT * FROM lob_test;
>
> OPEN o_cur_date FOR
> select sysdate from dual;
> end sp_lob_test;`
>
> _, err = session.PrepAndExe(createSpQry)
>
> if err != nil {
> panic(err)
> }
>
> SessionPool.Put(session)
>
> qry := "call sp_lob_test(:o_cur_lob, :o_cur_date)"
>
> for i := 0; i < 1000000; i++ {
>
> session, err := SessionPool.Get()
> if err != nil {
> panic(err)
> }
>
> stmt, err := session.Prep(qry)
>
> if err != nil {
> panic(err)
>
> }
>
> c1 := &ora.Rset{}
> c2 := &ora.Rset{}
>
> _, err = stmt.Exe(c1, c2)
>
> if err != nil {
> panic(err)
> }
> fmt.Printf("iteration #%d\n", i)
> fmt.Println(c1)
> fmt.Println(c2)
>
> stmt.Close()
> SessionPool.Put(session)
> }
>
> }
>
>
> —
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly, view it on GitHub
> <#233 (comment)>, or mute
> the thread
> <https://github.com/notifications/unsubscribe-auth/AAPoSm7pgFnnC5T1ij1CAGVD0ii6IBWOks5s2bYrgaJpZM4QdMF5>
> .
>
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Only from ORA-01000 errors. I've tried to reproduce it (z_db_test.go, z_session_test.go, Test_open_cursor, Test_open_cursor_db), without success. Maybe if you can tweak any of those tests to reproduce the error, the fix would be easier. |
Tamas,
The code I’ve sent reproduces this like a charm :)
… On 14 Nov 2017, at 22:00, Tamás Gulácsi ***@***.***> wrote:
Only from ORA-01000 errors. I've tried to reproduce it (z_db_test.go, z_session_test.go, Test_open_cursor, Test_open_cursor_db), without success. Maybe if you can tweak any of those tests to reproduce the error, the fix would be easier.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#233 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/ALjeJ9zDcZpxz6cAwj_PrhsLDEB4JxIwks5s2fFxgaJpZM4QdMF5>.
|
I suspect that the returned cursor are never closed - even if I call Exhaust on it. |
I guess some more RTFM is required...
Did you use my code to reproduce this sucker?
Cheers,
LK
… On Nov 14, 2017, at 11:35 PM, Tamás Gulácsi ***@***.***> wrote:
I suspect that the returned cursor are never closed - even if I call Exhaust on it.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Yes, see TestIssue233 in z_session_test.go |
If you change session.close to testSesPool.Put(session) it will fail even much faster.. :((( |
Hi! |
I think yes, and no. My instinct says that the problem is that there's no explicit close for the statement and rset, but close of Rset's close its Stmt, if there's no more opened Rset. I've moved the changes to "issue233" branch. |
Tamas, BTW, I've observed, that if you return cursors from prepared statement executed from the driver, rather than calling SP, the behaviour is different... With kind regards, |
gopkg.in/goracle.v2 is waay simpler, uses only database/sql and supports
returning cursors (as driver.Rows now, but may get better in the future -
chime in in https://groups.google.com/forum/#!topic/golang-sql/HNvcgScdyt8).
kogan69 <[email protected]> ezt írta (időpont: 2017. nov. 17., P,
6:50):
… Tamas,
I truly appreciate your effort! You've done one hell of the job on this
project and AFAIK this is the only solid attempt to give us enterprise
Oracle slaves :) a way to bring Go to the corporate world.
#223 <#223> is just a total No Go for
us, since 80% of our Oracle code is implemented as a stored procedures that
return cursors...
I'd really love to contribute to this project since it's of paramount
value in the success of Go in the enterprise, so if you need any help,
please, just let me know...
With kind regards,
LK
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#233 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAPoSvNwDx6Wa4RGvLotyolpCG4rInetks5s3R65gaJpZM4QdMF5>
.
|
I see. So what's the point of v4? |
rana/ora.v4 is older than goracle.v2
goracle.v1 is older than anything, it's a port of Python's cx_Oracle.
goracle.v2 is a rewrite of a driver from scratch for go1.9 as that allowed
Out params, for example.
(BTW goracle.v2 is based on ODPI-C which is a wrapper of the Oracle OCI C
library, written by Anthony Tuininga, the creator of cx_Oracle)
kogan69 <[email protected]> ezt írta (időpont: 2017. nov. 17., P,
9:43):
… I see. So what's the point of v4?
And another questions is if v2 is "bugs free" ? :)))
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#233 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAPoSpI5ngdGryT-C4K5yJf8TFG5XTj_ks5s3UcngaJpZM4QdMF5>
.
|
Tamas, many thanks! |
Hi!
Another trouble :)
I'm calling the same stored procedure for a number of times. The first 374 runs are OK, but on the run 375 it fails with ORA-28112
Another effect that I observe, is that the memory usage grows constantly. I've eliminated all of my code to isolate the case and made sure that only the driver's code is running. The memory leakage continued...
I've suspected that the cursors are not getting released and found out in debugger that the line stmt.go#193 (C.OCIHandleFree(unsafe.Pointer(ocistmt), C.OCI_HTYPE_STMT)) isn't called indeed...
It's just my speculation, but may be this is a reason for this effect?
Here's the code that eventually fails:
With kind regards,
LK
The text was updated successfully, but these errors were encountered: