#1 mORMot 2 » External table BatchSend raises SharedTransaction exception. » 2024-06-04 12:13:44

jienyuan
Replies: 2

I have two external SQL Table. Everything works fine when I use ORM add/update directly.

However, when I try using Batch to control transaction, exception occurs after BatchSend.

I am wondering whether is Batch control suitable for external tables?

Below is the code and log capture. Any idea is appreciated.

Thank you.

var
  aUId: RawUtf8;
  aBatch: TRestBatch;
  aLog: TOrmMyLog;
  aUser: TOrmUTbl;
begin
  aUId:= TSQLMyAuthUser(Session.User).UId;
  aBatch:=TRestBatch.Create(Sender.Orm,nil,10000);
  aLog:=TOrmMyLog.New(Ctxt,'SESSION');
  with aLog do begin
    DATA_1:='True';
    Data_2:='STANDARD';
  end;
  //Sender.Add(aLog,True);
  aBatch.Add(aLog,True);
  aUser:=TOrmUTbl.Create;
  Sender.Retrieve(csFilter,[],[aUId],aUser);
  with aUser do 
  begin
      Updated:=20240604;
      Invalidates:=0;
      LoggedIn:=True;
      LastLogin:=Now;
  end;
  //Sender.Update(aUser,aFields);
  aBatch.Update(aUser,aFields);  
  Sender.BatchSend(aBatch);
end;
2024/6/4 11:34:53.624	Trace	    MyRestServer.TMyRestServerDB(04fff520) BatchSend {"TRestBatch(04bd3de0)":{Count:2,SizeBytes:212}}
2024/6/4 11:34:53.624	Enter	    mormot.orm.server.TRestOrmServerBatchSend(04b647e0).EngineBatchSend  inlen=212
2024/6/4 11:34:53.624	Enter	       mormot.db.sql.zeos.TSqlDBZeosConnection(04be4a10).StartTransaction
2024/6/4 11:34:53.624	Leave	       00.001.169
2024/6/4 11:34:53.624	SQL	       mormot.db.sql.zeos.TSqlDBZeosStatement(0509b080) Execute t=1.99ms wr=1 q=insert into dbo.MyLOG (ID,LOGTIME,OPERATOR,ADDR,LOGACTION,DATA_1,DATA_2,MACHINEID,HOSTNAME) values ([32...],['2024-06-04T19:34:47.267'...],['USR'...],['127.0.0.1'...],['SESSION'...],['True'...],['STANDARD'...],['0'...],[''...])
2024/6/4 11:34:53.624	Cache	       mormot.db.raw.sqlite3.TSqlDatabase(04be4668)  cache flushed
2024/6/4 11:34:53.624	DB	       mormot.db.sql.zeos.TSqlDBZeosStatement(0509b350) Prepare t=530us q=update dbo.UTBL set UPDATED=?,LOGGEDIN=?,INVALIDATES=?,LASTLOGIN=? where ID=?
2024/6/4 11:34:53.624	SQL	       mormot.db.sql.zeos.TSqlDBZeosStatement(0509b350) Execute t=5.87ms wr=1 q=update dbo.UTBL set UPDATED=['20240604'...],LOGGEDIN=[1...],INVALIDATES=[0...],LASTLOGIN=['2024-06-04T19:34:47'...] where ID=[2...]
2024/6/4 11:34:53.768	Exception	       ESqlDBException {Message:"Unexpected TSqlDBZeosConnectionProperties.SharedTransaction(1,2)",Statement:null} [R0:MyServices] at 6852ff mormot.core.text.pas ESynException.RaiseUtf8 (9240)  
2024/6/4 11:34:59.880	Exception	       ESqlDBException {Message:"Unexpected TSqlDBZeosConnectionProperties.SharedTransaction(1,3)",Statement:null} [R0:MyServices] at 6852ff mormot.core.text.pas ESynException.RaiseUtf8 (9240)  

#2 Re: mORMot 2 » WebSocketsUpgrade with RemoteLogging caused ESynLogException » 2023-12-14 08:30:05

Hi Thomas,

   Thanks for the promptly reply.

I did the more testing and noticed my code is working fine when not used WebSocketsEnable() function.

I activated WebSocketsEnable() and noticed there will have logs in below:

 EXC   ENetSock {LastError:"nrFatalError",Message:"THttpClientSocket.SockSendFlush(localhost) len=539 [Fatal Error - #6]"} [TRemoteLog LogService] at 637c26
 EXC   ESynLogException {Message:"Missing TSynLog.DisableRotemoteLog(true)"} [R1:root] at 59826e
 trace mormot.net.ws.async.TWebSocketAsyncProcess(025bd5c0) ProcessStop: callbacks
 debug mormot.net.ws.async.TWebSocketAsyncProcess(025bd5c0) ProcessStop {"TWebSocketProtocolBinary(025a7530)":{Name:"synopsebin",URI:"root",RemoteIP:"172.17.112.1",UpgradeUri:"root",Encrypted:true,FramesInCount:1,FramesInBytes:33,Options:["pboSynLzCompress"],FramesInBytesSocket:66,FramesInCompression:-100,FramesOutCompression:100}}
 trace mormot.net.ws.async.TWebSocketAsyncProcess(025bd5c0) SendFrame 172.17.112.1 * focConnectionClose len=0
 warn  mormot.net.ws.async.TWebSocketAsyncProcess(025bd5c0) Destroy: no focConnectionClose SendFrame

 

However, this is too far for me.

Best Regards,
JienYuan

#3 mORMot 2 » WebSocketsUpgrade with RemoteLogging caused ESynLogException » 2023-12-13 09:31:56

jienyuan
Replies: 2

After I added

TRestHttpClient.CreateForRemoteLogging('localhost',TSynLog,8091) in restws_chatserver program;

  with TSynlog.Family do
    ....
  WebSocketLog := TSynLog; // verbose log of all WebSockets activity
  TRestHttpClient.CreateForRemoteLogging('localhost',TSynLog,8091);
  try
    ...
  end;

to redirect logs to Logview in rest-websockets sample.

The Client.ServerTimeStampSynchronize will hang and raised the exception in Logview.

[bold]EXC   ESynLogException {Message:"Missing TSynLog.DisableRotemoteLog(true)"} [R1:root] at 59826e  [/bold]

Have any idea? Thank you.

#4 Re: mORMot 1 » Service Record type Dynamic Array result for Delphi 7 has limitation? » 2017-07-22 14:27:15

Hi AB,

  Thanks for the reply.

I do read the thread and topic in the document.

But it noticed

If your application is developped on any older revision (e.g. Delphi 7, Delphi 2007 or Delphi 2009), you won't be able to automatically serialize records as plain JSON objects directly.

You have several paths available:

By default, the record will be serialized as binary, and encoded as Base64 text

So, I was wondering might Delphi 7 record will be serialized as binary, and encoded as Base64 text then pass to client.

Now, I see it.

Thanks again.

#5 mORMot 1 » Service Record type Dynamic Array result for Delphi 7 has limitation? » 2017-07-22 08:07:16

jienyuan
Replies: 3

I tried Record type Dynamic Array service result in Delphi 7.
However, the result lost information after 50th item in Delphi 7 but seems correct in Berlin.
Is it a limitation in mORMot 1.18 & Delphi 7 ?

The code is:

Type
   TCodeValue=packed record
       Code: string;
       Value: string;
   end;

  TCodeValueArray = array of TCodeValue;

  IServiceClient = Interface(IInvokable)
  ['{E1779C4E-C7E3-4F83-BF94-91E907774384}']
    function getLis: TCodeValueArray ;
  end;

 
  TServiceClient = class(TInjectableObjectRest,IServiceClient)
  public
    function getList: TCodeValueArray ;
  end;

 
function TServiceClient.getList: TCodeValueArray;
var
  x: integer;
begin
  SetLength(result,100);
  for x:=Low(result) to high(result)  do begin
    result[x].Code:=Format('User%0:.3d',[x]);
    result[x].Value:=Format('Name%0:.3d',[x]);
  end;
end;


test:
var
   d: TCodeValueArray;
   x: integer;
begin
   d:=c.getList;
   for x:=Low(d) to High(d) do
     writeln(d[x].code+'|'+d[x].value);
end; 
 
I only got this in Delphi 7.

  User000|Name000 (first)
  .
  .
  User049|Name049
  |
  |
  .
  .
  | (100th)

Board footer

Powered by FluxBB