You are not logged in.
Pages: 1
I have a rest service writed with mORMot1.18_lastest+zeoslib7.2.10+firebird3.0.7, compile with Lazarus2.0.12+fpc3.2.0 target linux-x64. I found a weird problem may crash service sometimes at batchsend , I can't figure out where is wrong, There is a test program to reproduce the error: download it
function write_TodayHQ_batch(fContent: variant): boolean;
var
aTodayHQ: TSQLTTodayHQ;
aBatch: TSQLRestBatch;
iLoop : Integer;
v: Variant;
begin
Result := False;
with _safe(fContent)^ do
begin
aBatch := TSQLRestBatch.Create(aRestServer, TSQLTTodayHQ, 200); //200 will error, change to 1000 everything ok
try
for iLoop := 0 to Count - 1 do
begin
v := Values[iLoop];
with _safe(v)^ do
begin
aTodayHQ := TSQLTTodayHQ.Create(aRestServer, 'FCode=?', [U['Code']]);
try
aTodayHQ.FCode := U['Code'];
aTodayHQ.FPClose := D['PClose'];
aTodayHQ.FOpen := D['Open'];
aTodayHQ.FClose := D['Close'];
aTodayHQ.FHigh := D['High'];
aTodayHQ.FLow := D['Low'];
aTodayHQ.FVolume := I['Volume'];
aTodayHQ.FAmount := D['Amount'];
if aTodayHQ.ID > 0 then
aBatch.Update(aTodayHQ)
else
aBatch.Add(aTodayHQ, True);
finally
aTodayHQ.Free;
end;
end;
end;
Result := (aRestServer.BatchSend(aBatch) = HTTP_SUCCESS);
finally
aBatch.Reset;
aBatch.Free;
end;
end;
end;
20210225 03082838 trace mORMotSQLite3.TSQLRestServerDB(7faccc592c10) BatchSend {"TSQLRestBatch(7faccc5ca140)":{"Count":594,"SizeBytes":83991}}
20210225 03082838 + mORMotSQLite3.TSQLRestServerDB(7faccc592c10).EngineBatchSend TSQLTTodayHQ inlen=83992
20210225 03082838 + SynDBZeos.TSQLDBZEOSConnection(7faccc5c9dc0).StartTransaction
20210225 03082838 - 00.000.351
20210225 03082838 DB SynDBZeos.TSQLDBZEOSStatement(7faccc529520) Prepare 968us update TTodayHQ set FCode=?,FPClose=?,FOpen=?,FClose=?,FHigh=?,FLow=?,FVolume=?,FAmount=? where ID=?
20210225 03082843 SQL SynDBZeos.TSQLDBZEOSStatement(7faccc529520) ExecutePrepared 79.58ms wr=200 update TTodayHQ set FCode='SZ300326',FPClose=11.25,FOpen=11.2,FClose=11.33,FHigh=11.64,FLow=11.09,FVolume=0,FAmount=208098038 where ID=3116
20210225 03082844 + SynDBZeos.TSQLDBZEOSConnection(7faccc5c9dc0).StartTransaction
20210225 03082844 - 00.000.034
20210225 03082845 SQL SynDBZeos.TSQLDBZEOSStatement(7faccc529520) ExecutePrepared 14.06ms wr=200 update TTodayHQ set FCode='SZ300530',FPClose=18.34,FOpen=18.3,FClose=18.54,FHigh=19.28,FLow=18.06,FVolume=0,FAmount=28962745 where ID=3316
20210225 03082847 + SynDBZeos.TSQLDBZEOSConnection(7faccc5c9dc0).StartTransaction
20210225 03082847 - 00.000.033
20210225 03082847 EXC EZSQLException ("SQL Error: Dynamic SQL ErrorSQL error code = -104Unexpected end of command - line 1, column 27. Error Code: -104. Invalid token The SQL: EXECUTE BLOCK(P0_0 VARCHAR(; ") [] at $0000000000841AB8 CHECKINTERBASE6ERROR, line 902 of ../FPC/zeoslib7.2/src/dbc/ZDbcInterbase6Utils.pas $0000000000841EED PREPARESTATEMENT, line 956 of ../FPC/zeoslib7.2/src/dbc/ZDbcInterbase6Utils.pas $0000000000853670 PREPARE, line 344 of ../FPC/zeoslib7.2/src/dbc/ZDbcInterbase6Statement.pas $000000000050F44B INTERNALBATCHSTOP, line 1153 of ../FPC/mORMot/SQLite3/mORMotDB.pas $0000000000669B5F PERFORMAUTOMATICCOMMIT, line 42979 of ../FPC/mORMot/SQLite3/mORMot.pas
20210225 03082860 EXC EORMException {"Message":"TSQLRestStorageExternal.InternalBatchStop(TSQLTTodayHQ).BatchMethod=mNone"} [] at $000000000050EB3D INTERNALBATCHSTOP, line 1057 of ../FPC/mORMot/SQLite3/mORMotDB.pas $000000000066967F ENGINEBATCHSEND, line 43225 of ../FPC/mORMot/SQLite3/mORMot.pas
20210225 03082862 trace mORMotSQLite3.TSQLRestServerDB(7faccc592c10) EngineBatchSend json=82 KB add=0 update=594 delete=0 TSQLTTodayHQ
Last edited by xwg (2021-02-25 05:12:08)
Offline
yes, here is a wrong "EXECUTE BLOCK"
2021-02-26T11:37:24.5850 (20584:0000000000F30040) FREE_STATEMENT
D:\TEST4\TEST.FDB (ATT_64, SYSDBA:NONE, UTF8, TCPv4:127.0.0.1/64026)
/mnt/d/test4/bin/fpc-linux64-Debug/project1:127
Statement 35:
-------------------------------------------------------------------------------
EXECUTE BLOCK(P0_0 VARCHAR(10) CHARACTER SET UTF8 = ?,P1_0 DECIMAL(18,4)=?,P2_0 DECIMAL(18,4)=?,P3_0 DECIMAL(18,4)=?,P4_0 DECIMAL(18,4)=?,P5_0 DECIMAL(18,4)=?,P6_0 DECIMAL(18,4)=?,P7_0 DECIMAL(18,4)=?,P8_0 BIGINT=?,P0_1 VARCHAR(10) CHARACTER SET UTF8 = ?,P1_1 DECIMAL(18,4)=?,P2_1 DECIMAL(18,4)=?,...
2021-02-26T11:37:24.5860 (20584:0000000000F30040) FAILED PREPARE_STATEMENT
D:\TEST4\TEST.FDB (ATT_64, SYSDBA:NONE, UTF8, TCPv4:127.0.0.1/64026)
/mnt/d/test4/bin/fpc-linux64-Debug/project1:127
(TRA_88, READ_COMMITTED | REC_VERSION | NOWAIT | READ_WRITE)
-------------------------------------------------------------------------------
EXECUTE BLOCK(P0_0 VARCHAR( //error here
0 ms
Last edited by xwg (2021-02-26 04:57:25)
Offline
I don't think this EXECUTE BLOCK is generated by mORMot.
We only generate such blocks for insertion, not update.
From the logs, we can see that mORMot is emitting standard UPDATE statements, not EXECUTE BLOCK.
Please check if it is indeed generated by ZEOS, and if it the case, report in their forum.
Offline
It look like it is zeoslib bug in ZDbcInterbase6Statement in line 373, when ArrayCount mod FMaxRowsPerBatch = 0, av occure.
if (ArrayCount <> FMaxRowsPerBatch) and (FBatchStmts[False].PreparedRowsOfArray <> (ArrayCount mod FMaxRowsPerBatch)) then
PrepareFinalChunk(ArrayCount mod FMaxRowsPerBatch); //final block of batch
change to
if (ArrayCount <> FMaxRowsPerBatch) and (ArrayCount mod FMaxRowsPerBatch > 0) and (FBatchStmts[False].PreparedRowsOfArray <> (ArrayCount mod FMaxRowsPerBatch)) then
PrepareFinalChunk(ArrayCount mod FMaxRowsPerBatch); //final block of batch
it look like ok
Last edited by xwg (2021-02-26 15:24:37)
Offline
@xwg
applied to 7.2-patches. Thank you. See: https://sourceforge.net/p/zeoslib/code-0/7344/
Regards, Michael
Offline
Pages: 1