You are not logged in.
Pages: 1
Only when the master server is restarted the sync works but only once.
In the slave log I can see the following repeated five times:
2023-10-05 09:24:14.640 Debug mormot.rest.sqlite3.TRestServerDB(035da1e0) RecordVersionSynchronizeSlaveStart(TORMUser) current=19 Subscribe(036ec488)
2023-10-05 09:24:14.640 Enter mormot.soa.client.TServiceFactoryClient(036fac98).InternalInvoke IServiceRecordVersion.Subscribe("User",19,1)
2023-10-05 09:24:14.640 Enter mormot.rest.http.client.TRestHttpClientWebsockets(03d93730).InternalUri POST
2023-10-05 09:24:14.640 Trace mormot.rest.http.client.TRestHttpClientWebsockets(03d93730) InternalRequest POST calling THttpClientWebSockets(03d939a0).Request
2023-10-05 09:24:14.640 Client mormot.rest.http.client.TRestHttpClientWebsockets(03d93730) POST DHSSync/ServiceRecordVersion.Subscribe status=200 len=18 state=1
2023-10-05 09:24:14.640 Leave 00.003.082
2023-10-05 09:24:14.640 Service return mormot.soa.client.TServiceFactoryClient(036fac98) {"result":[false]}
and then I get an error:
2023-10-05 09:24:14.704 Error mormot.rest.sqlite3.TRestServerDB(035da1e0) RecordVersionSynchronizeSlaveStart(TORMUser): retry failure
The code in the slave looks like this:
procedure TForm5.btnSynchronizeClick(Sender: TObject);
function setUpSyncServer: TRestServerDB;
begin
result := TSQLRestServerDB.Create(CreateSyncModel, ChangeFileExt(Executable.ProgramFileName, '.db'));
result.DB.Synchronous := smOff;
result.DB.LockingMode := lmNormal;
result.Server.CreateMissingTables;
end;
begin
if not fSyncRunning then
begin
btnSynchronize.Caption := 'Stopp Synk';
fSyncServer := SetUpSyncServer;
fHttpClientSync := TRestHttpClientWebSockets.Create('127.0.0.1', '8888', CreateSyncModel);
fSyncServer.RecordVersionSynchronizeSlaveStart(TORMUser, fHttpClientSync);
fSyncRunning := true;
end
else
begin
btnSynchronize.Caption := 'Synka';
fSyncServer.RecordVersionSynchronizeSlaveStop(TORMUser);
freeAndNil(fSyncServer);
freeAndNil(fHttpClientSync);
fSyncRunning := false;
end;
end;
The master part:
function setUpOrmSyncServer: TRestServerDB;
begin
result := TRestServerDB.Create(CreateSyncModel, ChangeFileExt(Executable.ProgramFileName, '.db'));
result.DB.LockingMode := lmNormal;
end;
begin
OrmSyncServer := setUpOrmSyncServer;
HttpSyncServer := TRestHttpServer.Create('8888', [OrmSyncServer], '+', UseBidirSocket,4 );
OrmSyncServer.RecordVersionSynchronizeMasterStart;
So I just wonder, What am I missing?
Delphi-11, WIN10
Offline
No answer in a week, I hoped to find some anwer here at least a comment if some necessary information is missing.
I tried to find a solution myself and I feel that I've done what is needed but in spit of that, no success.
I don't believe that this function is incomplete or not functional in mORMot2 but it looks so to me.
Last edited by larand54 (2023-10-13 11:20:58)
Delphi-11, WIN10
Offline
With such partial code, we can't reproduce your problem.
Take a look at the regression tests, you will see how master/slave replication is supposed to be used.
See TestMasterSlaveRecordVersion() procedure in
https://github.com/synopse/mORMot2/blob … 7C1-L627C1
Online
Hello ab,
I've already checked out that code and I did a new attempt with a small testproject but still fail.
I have this project available as a zip-file but I don't find any way to share that. PasteBin doesn't seem to to be used with anything but sourcefiles.
Any idea how I can share this file?
I have the project on GITLAB if it could work?
https://gitlab.com/GIT-Testing/test_mor … cation.git
I made a small program that more or less copies the code you have in your test suite.
That code works but the difference is that I don't use services here. When simulating changes in the master table I do it directly through the TRestServerDB instance.
But in the real world I need to use services and then I need 2 different http-channels, one for update the table on the master and one for the replication.
And this case don't work for me. See the the GITLAB-project above.
I'm sure that I have misunderstood how to do this correct but I'm also sure it must be someone, that have a working solution of a similar system like mine, that could see what I've done wrong or..?
Otherwise I have to develop a compleatly different solution on my own :-(
Please help.
Last edited by larand54 (2023-11-02 10:54:01)
Delphi-11, WIN10
Offline
Please see my updated reply above.
It seems that it only works once after that I erase the user table first and then start the slave.
The data is copied from master to the slave just after the call:
fSlave.RecordVersionSynchronizeSlaveStart(TOrmUser, fMasterClient, nil);
But not after.
Very strange or...?
Last edited by larand54 (2023-11-02 12:58:49)
Delphi-11, WIN10
Offline
I have another version written for Lazarus if that could be easier for someone to checkout.
https://gitlab.com/GIT-Testing/mormot-r … th-lazarus
This version works as bad as any other of my attempts to find a working solution.
Looks that it is not possible to have the real-time sync with this library.
//LG
Delphi-11, WIN10
Offline
Pages: 1