#1 2015-07-01 11:08:15

alexdmatveev
Member
Registered: 2014-09-12
Posts: 87

Duplicated blobs posted

Hello,

after some hours of fight I ask you about any idea...

I do not know what happened today but when I ask code above several time for different objects I have absolutelly identical blob fields for all created records in mysql.
All non-blob fields look good. They are different.

  FConnectionManager.DocumentClient.RetrieveBlobFields(form);
  LocalClient.Add(form, True, True);
  LocalClient.UpdateBlobFields(form);

Log from server for 2 records:

1:

20150701 12340157  +    TSQLRestServerDB(09ACBB30).URI(PUT root/OmFormDocument/5/Document inlen=90702)
20150701 12340157  +         TSQLDBUniDACStatement(10BC1F40).00CD6483 SynDBDataset.TSQLDBDatasetStatementAbstract.Prepare (449) 
20150701 12340157  -         00.000.222
20150701 12340157  +         TSQLDBUniDACStatement(10BC1F40).00CD65F5 SynDBDataset.TSQLDBDatasetStatementAbstract.ExecutePrepared (465) 
20150701 12340157 SQL             TSQLDBUniDACStatement(10BC1F40) update OmFormDocument set Document=*BLOB* where ID=5
20150701 12340201  -         00.091.883
20150701 12340201 srvr       TSQLRestServerDB(09ACBB30)   PUT root/OmFormDocument ORM-Write -> 200 with outlen=0 in 92263 us
20150701 12340201  -    00.092.334
20150701 12340201  +    TSQLRestServerDB(09ACBB30).URI(PUT root/OmFormDocument/5/Preview inlen=263947)
20150701 12340201  +         TSQLDBUniDACStatement(10BC2540).00CD6483 SynDBDataset.TSQLDBDatasetStatementAbstract.Prepare (449) 
20150701 12340201  -         00.000.271
20150701 12340201  +         TSQLDBUniDACStatement(10BC2540).00CD65F5 SynDBDataset.TSQLDBDatasetStatementAbstract.ExecutePrepared (465) 
20150701 12340201 SQL             TSQLDBUniDACStatement(10BC2540) update OmFormDocument set Preview=*BLOB* where ID=5
20150701 12340216  -         00.244.528
20150701 12340216 srvr       TSQLRestServerDB(09ACBB30)   PUT root/OmFormDocument ORM-Write -> 200 with outlen=0 in 244974 us
20150701 12340216  -    00.245.019

2:

20150701 12340628  +    TSQLRestServerDB(09ACBB30).URI(PUT root/OmFormDocument/13/Document inlen=134492)
20150701 12340628  +         TSQLDBUniDACStatement(10BC1F40).00CD65F5 SynDBDataset.TSQLDBDatasetStatementAbstract.ExecutePrepared (465) 
20150701 12340628 SQL             TSQLDBUniDACStatement(10BC1F40) update OmFormDocument set Document=*BLOB* where ID=13
20150701 12340633  -         00.073.610
20150701 12340633 srvr       TSQLRestServerDB(09ACBB30)   PUT root/OmFormDocument ORM-Write -> 200 with outlen=0 in 73712 us
20150701 12340633  -    00.073.760
20150701 12340633  +    TSQLRestServerDB(09ACBB30).URI(PUT root/OmFormDocument/13/Preview inlen=96058)
20150701 12340633  +         TSQLDBUniDACStatement(10BC2540).00CD65F5 SynDBDataset.TSQLDBDatasetStatementAbstract.ExecutePrepared (465) 
20150701 12340633 SQL             TSQLDBUniDACStatement(10BC2540) update OmFormDocument set Preview=*BLOB* where ID=13
20150701 12340639  -         00.100.866
20150701 12340639 srvr       TSQLRestServerDB(09ACBB30)   PUT root/OmFormDocument ORM-Write -> 200 with outlen=0 in 101018 us
20150701 12340639  -    00.101.104
20150701 12340639  +    TSQLHttpClientWinHTTP(0A07F980).00BD134E mORMotHttpClient.TSQLHttpClientGeneric.InternalURI (427) 
20150701 12340642 clnt       TSQLHttpClientWinHTTP(0A07F980) GET root?session_signature=3C1D9E470008644F33B00B40 status=200 state=1463
20150701 12340642  -    00.048.849

I see there correct inlen values. So I see I send correct values to write to DB...
But as result I have all blobs filled with values of first sent record's blobs.

My server and client code:

  aProps := TSQLDBUniDACConnectionProperties.Create('MySQL',
        settings.ReadString(logonName, 'mysql_database', 'mednet_default'),
        logonName,
        password);
  aProps.SpecificOptions.Values['Server'] := settings.ReadString(logonName, 'mysql_host', 'localhost');
  aProps.SpecificOptions.Values['Port'] := settings.ReadString(logonName, 'mysql_port', MYSQL_PORT);
  aProps.SpecificOptions.Values['UseUnicode'] := 'True';
  aProps.SpecificOptions.Values['Charset'] := 'utf8';
  FLocalModel := CreateLocalModel;

  VirtualTableExternalRegisterAll(FLocalModel, aProps, [regMapAutoKeywordFields]);

  FLocalRestServer := TSQLRestServerDB.Create(FLocalModel, SQLITE_MEMORY_DATABASE_NAME); // authentication=true
  FLocalRestServer.CreateMissingTables(0, [itoNoIndex4UniqueField, itoNoIndex4RecordReference, itoNoIndex4NestedRecord]); // create tables or fields if missing
//  FLocalRestServer.AcquireExecutionMode[execORMGet] := amBackgroundORMSharedThread;
//  FLocalRestServer.AcquireExecutionMode[execORMWrite] := amBackgroundORMSharedThread;

  FLocalClient := TSQLRestClientDB.Create(FLocalRestServer);

Have you any ideas ?

Thanks for advance.

Offline

#2 2015-07-01 13:06:10

alexdmatveev
Member
Registered: 2014-09-12
Posts: 87

Re: Duplicated blobs posted

in second and next requests I do not see next row in log...

TSQLDBUniDACStatement(10BC2540).00CD6483 SynDBDataset.TSQLDBDatasetStatementAbstract.Prepare (449) 

Does the server uses last prepared SQL from first transaction?

Offline

#3 2015-07-01 16:11:53

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,182
Website

Re: Duplicated blobs posted

From ORM point of view, TSQLRest.UpdateBlobFields() use its own current data.
Then TSQLDBDatasetStatement.DataSetBindSQLParam() should bind the BLOB content.

So perhaps there is indeed a problem with the statement.
For speed, the same statement is reused.
There may be an issue with TParam.SetBlobData() when the statement is reused.

Try to disable the statement cache in SynDB.pas:

function TSQLDBConnection.NewStatementPrepared(const aSQL: RawUTF8;
  ExpectResults: Boolean; RaiseExceptionOnError: Boolean=false): ISQLDBStatement;
...
  ToCache := FALSE;   /// fProperties.IsCachable(Pointer(aSQL));
...

Offline

Board footer

Powered by FluxBB