access violation at address in module OraOCIEI12.dll

cptngrb

Member²
Using session pool. When threads are greater than 70 in a procedure OracleSession.LogOn exception: "access violation at address in module OraOCIEI12.dll". And this does not happen often.

 
Action sequence:
1. OracleSession:= TOracleSession.Create(nil);
OracleSession.Pool:= Pool;
OracleSession.ThreadSage:= True;

2. OracleSession.LogOn;
OracleQuery.Session:= OracleSession;
OracleQuery.Execute;
OracleQuery.Close;
OracleQuery.Session:= nil;
OracleSession.LogOff;

the second paragraph is repeated in the cycle
 
3 Thread. I will describe the main points
--------------------
1

type
TListQuery = class
private
FCS: TCriticalSection;
FList: TObjectQueue;
FMaxCount: integer;
FType: byte;
FSize: integer;
public
constructor Create(const ACount, ASize, AMax, AType: integer); overload;
destructor Destroy(); override;
function GetCount: integer;
function PopQuery: TOracleQuery;
procedure PushQuery(AQuery: TOracleQuery);
end;
{ TListQuery }
constructor TListQuery.Create(const ACount, ASize, AMax, AType: integer);
var
i: integer;
begin
inherited Create;
FCS:= TCriticalSection.Create;
FList:= TObjectQueue.Create;
FMaxCount:= AMax;
if FMaxCount 0 then
Result:= FList.Extract;
finally
FCS.Leave;
end;
end;

procedure TListQuery.PushQuery(AQuery: TOracleQuery);
var
b: boolean;
begin
case FType of
0: begin
b:= True;
FCS.Enter;
try
if FMaxCount > FList.Count then
begin
FList.Enqueue(AQuery);
b:= False;
end;
finally
FCS.Leave;
end;

if b then
try
AQuery.Free;
except

end;
end;

1: begin
FCS.Enter;
try
FList.Enqueue(AQuery);
finally
FCS.Leave;
end;
end;

end;
end;
-------------------------------------------------
2/ SETVARIABLES
LIST_QUERY_CLEAR, LIST_QUERY_READY:TListQuery;

procedure Execute;
var
cntF: byte;
i: integer;
FQuery: TOracleQuery;
FObPack: TobPack;
begin

CSectionPackFull.Enter;
TRY
if ListPack_Analiz_Full.Count > 0 then
begin
FObPack := ListPack_Analiz_Full.Extract;
cntF:= 1;
end
else
cntF:= 0;
FINALLY
CSectionPackFull.Leave;
END;

if cntF = 1 then
begin

repeat
FQuery:= LIST_QUERY_CLEAR.PopQuery;
if Terminated then break;
if (SERVICE_STOP = 1) then begin
sleep(100);
break;
end;
TThread.sleep(10);
until not (FQuery = nil);

FQuery.SetVariable(0, FObPack.m1);
FQuery.SetVariable(1, FObPack.m2);
FQuery.SetVariable(2, FObPack.m3);
FQuery.SetVariable(3, FObPack.mm4);
FQuery.SetVariable(4, FObPack.m5);
FQuery.SetVariable(5, FObPack.m6);
FQuery.SetVariable(6, FObPack.m7);
FQuery.SetVariable(7, FObPack.m8);
FQuery.SetVariable(8, FObPack.cnt);

CSectionPackNull.Enter;
TRY
ListPack_Analiz_Null.Enqueue(FObPack);
FINALLY
CSectionPackNull.Leave;
END;
LIST_QUERY_READY.PushQuery(FQuery);

end;
end;

end.

3////------------------------------

OSPOOL: TOracleSessionPool;
OSPOOL:= TOracleSessionPool.Create(nil);
OSPOOL.Homogeneous:= True;
OSPOOL.Max:= MAX_SESSION_COUNT;
OSPOOL.LogonUsername:= user_name;
OSPOOL.LogonPassword:= passwd;
OSPOOL.LogonDatabase:= con_str;
OSPOOL.TimeOut:= 120;

procedure TDBPacket.ComitPack;
var
FQuery: TOracleQuery;
begin
repeat
FQuery:= LIST_QUERY_READY.PopQuery;
if Terminated or (SERVICE_STOP = 1) then exit;
if reloadOCI = 1 then exit;
if err_conn_db = 1 then exit;
TThread.sleep(10);
until not (FQuery = nil);

ReconnectServer;
FQuery.Session:= oraSession;
FQuery.Execute;
FQuery.Close;

FQuery.Session:= nil;
LIST_QUERY_CLEAR.PushQuery(FQuery);
oraSession.LogOff;
end;

procedure TDBPacket.InitSession;
begin
oraSession := TOracleSession.Create(nil);
oraSession.ThreadSafe := False;
oraSession.StatementCache:= True;
oraSession.Preferences.ConvertCRLF:= false;
oraSession.Preferences.TrimStringFields:= false;
oraSession.Pooling:= spInternal;

end;

function TDBPacket.ReconnectServer: boolean;
var
Start: Cardinal;
begin

Result:= False;
oraSession.Pool:= OSPOOL;
oraSession.LogOn; ECXEPTION HERE
Result:= True;

end;

end.
 
Last edited:
type
TobPack = class
m1: Variant;
m2: Variant;
m3: Variant;
m4: Variant;
m5: Variant;
m6:Variant;
m7: Variant;
m8: Variant;
cnt_pack: integer;
constructor Create(const dbSize: integer); overload;
destructor Destroy; override;
end;

{ TobPack }

constructor TobPack.create(const dbSize: integer);
begin
inherited Create;
try
m1 := VarArrayCreate([0, dbSize-1], varOleStr);
m2 := VarArrayCreate([0, dbSize-1], varOleStr);
m3:= VarArrayCreate([0, dbSize-1], varOleStr);
m4:= VarArrayCreate([0, dbSize-1], varInteger);
m5:= VarArrayCreate([0, dbSize-1], varInteger);
m6:= VarArrayCreate([0, dbSize-1], varInteger);
m7:= VarArrayCreate([0, dbSize-1], varDate);
m8:= VarArrayCreate([0, dbSize-1], varDate);
except
on e : Exception do
WriteLog(e.Message);
end;
end;

destructor TobPack.Destroy;
begin
try
m1 := null;
m2 := null;
m3:= null;
m4:= null;
m5:= null;
m6:= null;
m7:= Null;
m8:= Null;
finally
inherited Destroy;
end;
end;

 
function AddQuery(ASize: integer): TOracleQuery;
var
Q: TOracleQuery;
begin
Result:= nil;
try
Q:= TOracleQuery.create(nil);
// Q.Session:= ASession;
Q.DeleteVariables;
Q.Sql.Text:='begin' + #13#10 +
' pinsert__buf(m1 => :m1,' + #13#10 +
' m2 => :m2,' + #13#10 +
' m3 => :m3,' + #13#10 +
' m4 => :m4,' + #13#10 +
' m5 => :m5,' + #13#10 +
' m6 => :m6,' + #13#10 +
' m7 => :m7,' + #13#10 +
' m8 => :m8,' + #13#10 +
' v_cnt => :v_cnt);' + #13#10 +
'end;';

Q.DeclareVariable('m1', otDate);
Q.DimPLSQLTable('m1', ASize, 0);
Q.DeclareVariable('m2', otDate);
Q.DimPLSQLTable('m2', ASize, 0);
Q.DeclareVariable('m3', otString);
Q.DimPLSQLTable('m3', ASize, 10);
Q.DeclareVariable('m4', otString);
Q.DimPLSQLTable('m4', ASize, 10);
Q.DeclareVariable('m5', otString);
Q.DimPLSQLTable('m5', ASize, 10);
Q.DeclareVariable('m6', otInteger);
Q.DimPLSQLTable('m6', ASize, 0);
Q.DeclareVariable('m7', otInteger);
Q.DimPLSQLTable('m7', ASize, 0);
Q.DeclareVariable('m8', otInteger);
Q.DimPLSQLTable('m8', ASize, 0);
Q.DeclareVariable('v_cnt', otInteger);
Q.Optimize:= True;
Result:= Q;
except
on E: Exception do
WriteLog(E.Message);
end;

end;
 
sequencing of actions

OracleSession.Pool:= OracleSessionPool;
OracleSession.LogOn; //sometimes here is the error
OracleQuery.Session:= OracleSession;
OracleQuery.Execute;
OracleQuery.Close;
OracleQuery.Session:= nil;
OracleSession.LogOff;
 
Last edited:
Back
Top