Concurrent Access to xml field
Posted: Mon 03 Nov 2008 18:51
Hi,
our team has encountered the following problem:
- Given a simple table with a single numerical id on Oracle 10g.
- Given two thread each owning his TOraSession and TOraQuery the following sql text (our resultset row count doesn't exceed 100 rows):
sometimes invocation raise one of the following error:
- kgepop: no error frame to pop to for error 21500
- External exception EBAD53FC
- EAccessViolation in ... oraclient10.dll
- EAccessViolation in ... orageneric10.dll
The first of which is a blocking error and the message was visible only if "Generate console application" is checked.
A possible but not acceptable workaround consist in setting "FetchAll" to true in TOraquery and protect query Open with a global critical section.
Besides the obviuos problem coming from a "global critical section" this workaround reduce but *doesn't resolve* the problem.
Our Environment:
Odac Version 6.50.0.39
Oci Version 10
Oracle 10g
Delphi 2007
Some useful snippet to reproduce the bug
Thread Body
XmlSaveClob:
Thanks all.
our team has encountered the following problem:
- Given a simple table with a single numerical id on Oracle 10g.
- Given two thread each owning his TOraSession and TOraQuery the following sql text (our resultset row count doesn't exceed 100 rows):
Code: Select all
SELECT XMLFOREST(IJ.SIMPLE_ID) XML_FIELD
FROM TEST_TABLE IJ ;
Code: Select all
Next
- kgepop: no error frame to pop to for error 21500
- External exception EBAD53FC
- EAccessViolation in ... oraclient10.dll
- EAccessViolation in ... orageneric10.dll
The first of which is a blocking error and the message was visible only if "Generate console application" is checked.
A possible but not acceptable workaround consist in setting "FetchAll" to true in TOraquery and protect query Open with a global critical section.
Besides the obviuos problem coming from a "global critical section" this workaround reduce but *doesn't resolve* the problem.
Our Environment:
Odac Version 6.50.0.39
Oci Version 10
Oracle 10g
Delphi 2007
Some useful snippet to reproduce the bug
Thread Body
Code: Select all
procedure TTryThread.Execute;
var
Fields: TFields;
PacketOut: TMemoryStream;
buf, zbuf: TMemoryStream;
begin
inherited;
while not terminated do
begin
OraQuery.Open;
try
PacketOut := TMemoryStream.Create;
try
if not OraQuery.Eof then
begin
Fields := OraQuery.Fields;
buf := TMemoryStream.Create;
zbuf := TMemoryStream.Create;
try
while not OraQuery.Eof do
begin
XmlSaveClob(OraQuery, 'xml_field', PacketOut, buf);
OraQuery.Next;
end;
finally
buf.Free;
zbuf.Free;
end;
end;
PacketOut.position := 0;
PacketOut.size := 0;
finally
PacketOut.Free;
end;
finally
OraQuery.Close;
end;
end;
end;
Code: Select all
procedure XmlSaveClob(aResultSet: TObject; aFieldName: string; aDst, aBuf: TMemoryStream);
var
sz: cardinal;
ws: WideString;
begin
aBuf.Position := 0;
aBuf.Size := 0;
ws := TOraXMLField(TOraDataSet(aResultSet).FieldByName(aFieldName)).AsXML.asString;
aBuf.WriteBuffer(ws[1], length(ws) * 2);
sz := aBuf.Size + 22 {tag widestring};
aDst.WriteBuffer(sz, 4);
ws := widestring('');
aDst.WriteBuffer(ws[1], length(ws) * 2);
aBuf.Position := 0;
adst.CopyFrom(aBuf, aBuf.size);
ws := widestring('');
aDst.WriteBuffer(ws[1], length(ws) * 2);
end;