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

Attachments failed to replicate when deleted and recreated #1440

Closed
sethrosetter opened this issue Sep 13, 2016 · 6 comments
Closed

Attachments failed to replicate when deleted and recreated #1440

sethrosetter opened this issue Sep 13, 2016 · 6 comments

Comments

@sethrosetter
Copy link
Contributor

sethrosetter commented Sep 13, 2016

This also fails with Android (1.3.1-30) and .NET (1.3.1-13)

Failing test - https://github.com/couchbaselabs/mobile-testkit/blob/feature/add-multiple-sg-replication-test/testsuites/listener/shared/client_sg/attachments.py#L14-L86

Steps to reproduce:

  1. Start continuous replication between LiteServ and Sync Gateway
  2. Add a few docs with large attachements to LiteServ
  3. Immediately after delete the docs on LiteServ
  4. Recreate the docs on LiteServ with the same id and attachment (rev = 3-xxxxx)
  5. The recreated attachement docs do not sync to sync gateway

Expected: Recreated attachment docs would sync
Actual: They do not

I am seeing these errors in the logs

14:21:50.655‖ WARNING: CBLRestPusher[http://192.168.0.49:4985/db]: _bulk_docs got an error: {
    error = "bad_request";
    id = "large_attach_0";
    reason = "Missing digest in stub attachment \"golden_gate_large.jpg\"";
    status = 400;
} {at __40-[CBLRestPusher uploadBulkDocs:changes:]_block_invoke:402}
14:21:50.655‖ WARNING: CBLRestPusher[http://192.168.0.49:4985/db]: _bulk_docs got an error: {
    error = "bad_request";
    id = "large_attach_1";
    reason = "Missing digest in stub attachment \"golden_gate_large.jpg\"";
    status = 400;

  • Version: 1.3.1-6
  • Client OS: Mac OSX
  • Server: Sync Gateway 1.3.1-16
@borrrden
Copy link
Member

borrrden commented Oct 1, 2016

@borrrden
Copy link
Member

borrrden commented Oct 1, 2016

Analysis:

return @{@"stub": @YES, @"revpos": @(revPos)};
this is the offending area. Include the digest here (it is already on attachment in this case, but need to confirm that this is a valid thing to do. It seems that there is already a stub in this case so really the attachment doesn't need mutating I think?) and the test can proceed. .NET will pass the test with this change and a small .NET specific one.

@snej
Copy link
Contributor

snej commented Dec 12, 2016

I'm not clear how that line relates to this bug. If the doc was deleted and then recreated, doesn't the new revision's attachment have a revpos=3? If so, it wouldn't hit the offending line.

@borrrden
Copy link
Member

borrrden commented Dec 13, 2016

It doesn't. It still has revpos=1 (in some cases...)

@borrrden
Copy link
Member

Analysis: The following sequence triggers this behavior:

  1. PUT document with attachment
  2. DELETE document
  3. PUT document with attachment and no rev-id

In particular the third call without the revid causes the process attachments method to get a nil previous revision and default to generation 1

@pasin pasin added ready and removed backlog labels Dec 21, 2016
@pasin pasin self-assigned this Dec 21, 2016
@pasin
Copy link
Contributor

pasin commented Dec 22, 2016

Once couchbase/couchbase-lite-net#790 is merged, I can port the fix to the iOS platform.

@pasin pasin added backlog and removed ready labels Dec 22, 2016
@pasin pasin added review and removed backlog labels Jan 14, 2017
pasin added a commit that referenced this issue Jan 16, 2017
Per code review, add checking if there are no attachments.

#1440
@snej snej closed this as completed in 40ee89e Jan 16, 2017
@snej snej removed the review label Jan 16, 2017
pasin added a commit that referenced this issue Jan 24, 2017
* when a doc is deleted and recreated, inPrevRevID will be nil so the previous code to fix the attachment revpos doesn’t get executed.
* Simplify the code.

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

No branches or pull requests

5 participants