#300 - fixing issue causing dataloss when server session is lost whil… #353
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
…e client sends additional batches
1 - solves data loss issue
The issue is, that the
WebServerOrchestrator
just creates a newclientBatchInfo
if it is null.The issue with this is: If you send changes in batches and the server session is lost (e.g. due to an ApplicationPool recycle or because the Redis cache was cleared), it will just forget all the batches that were already sent during the ongoing session!
See the following sequencediagram for clarification:
The only thing I had to add to fix this is a null-check:
Interestingly, your code does check whether the session is empty when the client is requesting additional batches.
So I just added a test to cover the fact that this will also not break in the future.
2
HttpMessageSendChangesRequestArgs
takes abyte[]
- what for?I had to implement "OnReceiveChanges" interception
Why is the parameter
HttpMessageSendChangesRequestArgs
ofOnSendChanges
taking the binary data as a parameter?I would argue, that when I do intercept this call, I would like to see what changes are sent.
But in the current implementation, I only do get a byte array.
The only thing I could think of was to manipulate this array to e.g. add another layer of compression/encryption. Is that the intention?
As I did not see any real sense in that, I removed this.
Instead (and also in order to create an integration test for this scenario) I changed the constructor to take a
HttpMessageSendChangesRequest
as a parameter instead of thebyte[]
:Likewhise, I had to add
HttpMessageSendChangesRequest
to theHttpMessageSendChangesRequestArgs
Additionally, the Interception happens before the changes are serialized.
That way, the interceptor can actually modify the changes sent to the server!
3 - Added integration test to ensure deferred transaction are never used by SqliteSyncProvider
Additionally, I added a specific integration test that ensures that the SqliteSyncProvider does not use deferred transactions when selecting local changes as this can also lead to data loss in the future!