#1 Re: mORMot 1 » TSQLDBServerHttpApi with tmThreadPool » 2022-07-20 21:15:36

mpv wrote:

Made your descendant of TSQLDBServerHttpApi to access protected FServer: THttpServerGeneric TSqlDBServerAbstract member.
Add FServer.OnHttpThreadTerminate handler, and inside added handles call Properties.EndCurrentThread
Pseudo-code:

  
FHttpServer.FServer.OnHttpThreadTerminate = function() begin Properties.EndCurrentThread; end;

As alternative - use an ODBC connection instead of OleDB


Thank you.  I will try that.

#2 mORMot 1 » TSQLDBServerHttpApi with tmThreadPool » 2022-07-19 19:15:54

steve888
Replies: 4

I have noticed some problems with TSQLDBServerHttpApi when using a thread pool with TOleDBMSSQL2012ConnectionProperties.  The Ole CoUninit assertion seems to fail at times.

The Server runs in a Windows Service:

FProps := TOleDBMSSQL2012ConnectionProperties.Create('127.0.0.1\SQLEXPRESS','test','test','test');
FHttpServer := TSQLDBServerHttpApi.Create(FProps,'test',80,'test','test',False,64,nil,tmThreadPool);


The Client connection is created in a datamodule constructor and freed in the destructor:

http := TSQLDBWinHTTPConnectionProperties.Create(...)

statement := http.NewThreadSafeStatementPrepared(SomeSQL,True,True);

....parameter binding....

statement.ExecutePrepared;


Seeing this in the log at times:
20220715 06004760  ' ERROR "EAssertionFailed(125fef00)":"You should call TOleDBConnection.Free from the same thread which called its Create: i.e. call MyProps.EndCurrentThread from an THttpServerGeneric.OnHttpThreadTerminate event - see ticket 213544b2f5

Memory allocation seems to keep increasing over time because of this.  .  I tried using a HttpThreadTerminate event calling TSQLDBConnectionPropertiesThreadSafe(FProperties).EndCurrentThread, but the problem persists;  Please help.

#3 Re: mORMot 1 » FetchAllToBinary - Too Many Columns » 2018-07-30 22:01:45

ab wrote:

Sadly it is hardcoded...

Yes, TSqlDbProxyStatementColumns is a set limited to 256 elements.  Changing this to an array is a way around this limit.

#4 mORMot 1 » FetchAllToBinary - Too Many Columns » 2018-07-29 04:01:50

steve888
Replies: 7

I'm having a problem with a stored procedure that returns 300+ columns.  FetchAllToBinary throws a 'Too Many Columns' exception.  Unfortunately I'm unable to modify the procedure to return less columns.  Any suggestions?

  FillChar(Null,sizeof(Null),0);
  result := 0;
  W := TFileBufferWriter.Create(Dest);
  try
    W.WriteVarUInt32(FETCHALLTOBINARY_MAGIC);
    FMax := ColumnCount;
    W.WriteVarUInt32(FMax);
    if FMax>0 then begin
      // write column description
      SetLength(ColTypes,FMax);
      dec(FMax);
      for F := 0 to FMax do begin
        W.Write(ColumnName(F));
        ColTypes[F] := ColumnType(F,@FieldSize);
        W.Write1(ord(ColTypes[F]));
        W.WriteVarUInt32(FieldSize);
      end;
      // initialize null handling
      NullRowSize := (FMax shr 3)+1;
      if NullRowSize>sizeof(Null) then                     <-------------------------
        raise ESQLDBException.CreateUTF8(
          '%.FetchAllToBinary: too many columns',[self]);

#5 Re: mORMot 1 » HTTP remote - WinHTTP.dll error 12002 (The operation timed out) » 2018-07-27 08:14:07

Thanks for the reply.  I got it working by calling RegisterCompress and by increasing the send/recieve timeouts.  Now I'm having another problem with a stored proc that returns 300+ columns.  FetchAllToBinary throws a 'Too Many Columns' exception.  Any suggestions?

#6 Re: mORMot 1 » HTTP remote - WinHTTP.dll error 12002 (The operation timed out) » 2018-07-19 23:02:29

ab wrote:

Does 50k rows and 100+ columns take more than 20 seconds to be retrieved on server side?

Negative.  It executes in SSMS after about 2 seconds.  I also ran a trace on the server and it was also done in about 2 seconds.

#7 Re: mORMot 1 » HTTP remote - WinHTTP.dll error 12002 (The operation timed out) » 2018-07-19 09:28:18

Does anyone have any suggestions?  Should I attempt to use a specific type of compression?  Any examples/suggestions would be very much appreciated.

#8 mORMot 1 » HTTP remote - WinHTTP.dll error 12002 (The operation timed out) » 2018-07-17 08:38:42

steve888
Replies: 5

I'm attempting to migrate an old legacy project from ADO/Soap to something a little faster.  TSQLDBServerHttpApi seems to be working fine for normal selects, inserts and stored procedures.  My problem is with stored procedures that return very large result sets that are need for certain reports (up to 50k rows and 100+ columns -  Unfortunately I'm unable to change the logic for these stored procedures).  I'm getting WinHTTP.dll timeouts on the client after about 20 seconds.  I have tried increasing the client KeepAliveMS with no success.  Any help would be appreciated.

Server:

    Props := TOleDBMSSQL2012ConnectionProperties.Create('127.0.0.1','ReportsDB','user','password');
    HttpServer := TSQLDBServerHttpApi.Create(Props,'ReportsDB','8787','user','password');
    HttpServer.Properties.ConnectionTimeOutMinutes := 2;

Client:

  http := TSQLDBWinHTTPConnectionProperties.Create('1.2.3.4:8787','ReportsDB','user','pass');

  try
    ds := TDataSet.Create(Self);
    sql:= 'exec GetReportsSP param1, param2, param3';
    ds := ToDataSet(ds,http.Execute(sql,[]));
    PopulateGrid(ds);
  finally
    ds.Free;
  end;

Board footer

Powered by FluxBB