Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with DELETE commands hosting the orchestrator inside a Windows Service #911

Open
luc-cap opened this issue Dec 21, 2022 · 7 comments

Comments

@luc-cap
Copy link

luc-cap commented Dec 21, 2022

Hi,
I use Dotmim.Sync for at least 3 years.

I am implementing a Sync Solution where components invoved are
a WindowsService one side and a ASP.Net Core Controller on the other side.

On both sides there are two SQL server 2019.

As first STEP, I made a .NET Core 5.0 console App which is able to
estabish a connection between DB.

In particular, i wrote a console application from the examples, making the appropriate changes
and calling the method:
- SyncThroughWebApiAsync()
in:
- Dotmim.Sync-master\Samples\Dotmim.Sync.SampleConsole\Program.cs
all works fine !

As second step i implemented the Windows Service.

The same code, written for the orchestrator, does not Transmit DELETE RECORD !

Detetions from the server side are not received Client Side
and Detetions from the client side are not received Server Side.

Tracking of records are done from both sides.

This thing happens only with a Windows Service

My Windows service Solutions uses a dependency ingjection container,
and I Mapped Tables as Entities.
Tracking tables, instead, are not mapped as entities,
also because I think it's not right to do so.

When I remove provisioning ClientSide and ServerSide,
after a Sync with Reinitialize,
server side deletions are received from the client side.

I don't know how to fix this thing... Any Idea ?

I am using SqlSyncProvider for sync ( DotMim version: v0.8.1)
because I prefer it to SqlSyncChangeTrackingProvider.

Windows service uses .NET 6
Controller WEB in ASP.NET 6

best regards

@Mimetis
Copy link
Owner

Mimetis commented Dec 21, 2022

Can you try with the last version (v0.9.8) and see if it's changing something?
To be able to debug this error, I would suggest making a test with the new version on a new fresh server database (without any DMS metadata installed) and new client.

Just to ensure there is no collision with the previous version

Let me know if it's resolving your issue.

@luc-cap
Copy link
Author

luc-cap commented Dec 21, 2022

Unfortunately I tried to download and recompile
also the sources with TAG: 9.6.

I think there are some problems at Execution Context level.

Launching sync from a service is different than launching sync from a console app.

In other projects,
the same REST API hosted in a console App
they returned correct data,

But if hosted in a windows service, they had trouble reading
tables written by external programs.

The same thing happens for DMT Metadata tables.

Entities are modified from Entity framework... DMT Metadata table via a sql connection object .
Thus, after windows service start, the orchestrator no longer accesses the updated version of the on-premise metadata.

In other projects,
the same REST API hosted in a ConsoleApp returns correct data,

But if hosted in a windows service, they had trouble reading
tables written by external programs.

The same thing happens for DMT Metadata tables.

Entities are modified from Entity framework... DMT Metadata table via a sql connection object .
So, probably, after windows service start, the orchestrator no longer accesses to the updated version of the on-premise metadata.

@Mimetis
Copy link
Owner

Mimetis commented Dec 21, 2022

Do you think you are able to create a small github sample repro, that reproduce the error and that I can easily debug ?

@luc-cap
Copy link
Author

luc-cap commented Dec 22, 2022

I will do a repo after fixing the situation in production.

It will take me a while

Please, as Gihub administrator, leave the Iussue opened and rename it to:

"Implement an example for Windows Service against a WEB Api"

In the meantime, if someone solves it with a pull request... so be it.

bye

@luc-cap
Copy link
Author

luc-cap commented Dec 23, 2022

I did some tests Changing the SQL Server Sync Provider...

Test was this:

       1.  I create an order with 3 detail rows,
            setting for a row  an incorrect quantity.
       2.  So I delete the row and I re-entered a new row with the right quantity.

I have done this test 2 times, changing the providers.

Using SqlSyncChangeTrackingProvider the Client receives rows correctly.

Using the SqlSyncProvider, only the Insert-tracking take effect.
The delete-tracking is not received client side, so on-premise we have an extra row.

Using the SqlSyncProvider, all work fine only if between INSERT and DELETE we call a SYNC:
1. Insert
2. Sync
3. Delete
4. Sync

So it seems that there is a problem in the SqlSyncProvider doing the INS+DELETE of the record and a SYNC ( in a short Time ? ! ?) ...
Instead, with SqlSyncChangeTrackingProvider everything works fine.

@Mimetis
Copy link
Owner

Mimetis commented Dec 23, 2022

Thank you for trying hard to debug what's wrong :)

Can you share a GitHub repo I can use to reproduce the error? (And maybe a quick readme.md file to setup everything?)

@Mimetis
Copy link
Owner

Mimetis commented Jan 16, 2023

any news regarding this @luc-cap ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants