-
Notifications
You must be signed in to change notification settings - Fork 126
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
Replication Push is failing when attachments are involved #449
Comments
By the way, this is the content that exists on the server side:
Not sure if it helps creating an Unit test or something. |
Just out of curiosity, have you considered using Sync Gateway and Couchbase Server instead of CouchDB? CouchDB is not technically an officially supported endpoint for Couchbase Lite. It's more of a best effort. I'm not saying you have to switch but I just wanted to make sure you knew about this situation. |
I'm not sure but the guy that researched this before told us to use couchDB and started with it. I think it was something related to the HTTP API's |
I see, well just letting you know that we have a cloud product that we officially support for future reference ;). It also adds on a few more neat features that CouchDB doesn't have. You can find out more about it here: http://developer.couchbase.com/mobile/develop/guides/sync-gateway/ I'll still take a look at CouchDB related stuff though, but just know that replication with CouchDB is not as well tested as replication with Sync Gateway. |
Oh thanks. For future projects will consider using that then =). But on this one we can't change now unfortunately because it is already big and other things. |
@borrrden just by curiosity, is this working with sync gateway? |
It should. I have around 2-3 dozen integration tests that test various replication scenarios with sync gateway (including attachments). I'll set up a test for CouchDB as well when I have a chance. If you want to submit one, that would push things along even faster. |
You mean a little project that replicates the issue? But for that I will also need an online server with records causing the problem right? |
What I do is I start an instance of CouchDB on localhost and try to add similar items via C# REST calls. You can see some examples in my replication tests, for example https://github.com/couchbase/couchbase-lite-net/blob/master/src/Couchbase.Lite.Tests.Shared/ReplicationTest.cs#L669-L676 |
Ah ok. I do not have yet too much experience writing tests but, if I have some time available to try to make something similar to that, I will let you know here. But I don't think I will be able to do it today. |
Ok, I'm currently trying to make a Xamarin Android Unit Tests project for this issue against CouchDB. Will let you know when done :) |
You can use the tests in the repo as examples to help you out. They are all |
I tried to make a rebuild of them but I get error on |
If it's an nunit test like the others then make a pull request. Otherwise
put the main logic into a gist.
|
Ok @borrrden, I've been able to replicate this on a Unit Test project (but I think the test is not done as it should but works to see the issue).
Here's the gist |
Great job! With some slight tweaking I will be able to throw this right in alongside the other unit tests we have! I'll let you know when I've done that. |
Thanks :) |
Ok I've figured out what is going wrong, and a fix. I've also confirmed that this behavior happens in iOS native as well so I need to talk to the rest of the team to figure out if the behavior is intentional or not. |
Ok, thanks. Let me know then if it will have a fix or how this should be handled. |
Did you confirm it with CBL/iOS 1.1 or with the master branch? |
It was with the master branch but, I might have mine out of date. Let me try pulling the most recent one and test again tomorrow. |
@reyalpsirc I think that comment was for me. |
Ok. Anyway, I tested this with the most recent version on the master ( |
Right, I didn't include the fix yet because I need to confirm with the Sync Gateway team first on whether or not this will cause issues with Sync Gateway. But I will post an update after we have talked about it. |
Ok, thanks @borrrden, for everything :) |
By the way, because of this issue, if a record is changed directly on Futon during tests, the continuous pull replication will work but, future pushs made through continuous push replication will also cause a |
@borrrden Is it possible to make a fix on a separate branch temporarily? I need to finish a code until Friday that is dependent of this =/ |
I have put my tentative fix into the |
Oh, thanks :D. Gonna try it out then. |
@borrrden I tried it out but, has soon as I update the document via Futon, the pull replication gets it but, once I change it on the app, the push replication fails again with same error ( |
What about your unit test? Is that working? |
Oh wow, I'm sorry. I pushed some other stuff to that branch but not the actual fix. Update your branch and try again. |
I tested with that fix now and I got other error on the UnitTest:
I also tested this on my project and I get other error while it is pulling the records:
This one seems weird to me because according to your code, it would mean that the attachment has no |
Interesting. What do you get when you get that revision in the browser (not through FUTON)? You can issue a command to http://:5984//1d317ef4d2e579658427c6273d0017c4?rev= 118-2f382124afaa5953af7eaa34b97fb17e EDIT It also wouldn't hurt for me to ask what version of CouchDB you are using to make sure I am using the same one. I am on 1.6.1 |
I'm using the 1.6.0 version of CouchDB.
|
That all looks fine, but without the complete revision history to test on I cannot be more specific. I pushed a possible fix for the null reference exception you showed though. |
It still gave the exception:
So I will delete and re-add the document to check if it works (so that we know if it is an older revision problem) |
Ok, after some time, I've been ablet to delete, purge and compact the document completely (there was indeed something wrong with him before but I'm sure it was now deleted since CouchDb was saying "missing" to his id). Now I tried to create the document with the same id and the I added the image through the form of our web project and so, I got to this data:
After that, I tried it again and got the same error:
So, the error persists but, since now I only have 2 more revisions, here goes the content of each one:
Rev 1:
|
@reyalpsirc Thanks to that data I was able to find the problem. Check the latest update on the branch (actually only one character needed to be changed). |
It worked! Thanks @borrrden :). |
I was trying to change a document on the couchDB server and found out that the replication is failing when pushing the data:
And later, when it retries the push, it also gives this:
But since that was a retry and in order to check what was happening, I've used Wireshark on the background to inspect the data sent to the server and found out that it was giving this error:
So, given that I inspected what was being sent to the request and found out that everything was being sent less some parts of the attachments. This is what is getting sent in relation to the attachments:
And this is what my
Debug.WriteLine()
gives when I call my save function:Might the problem be because the record on the couchDB server have the attachments as MD5? Because since the replication fails, they do not get updated to the SHA1
The text was updated successfully, but these errors were encountered: