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

Rev pruning algorithm deletes entire revtree if only branch is a tombstoned branch #2695

Closed
tleyden opened this issue Jun 28, 2017 · 4 comments

Comments

@tleyden
Copy link
Contributor

tleyden commented Jun 28, 2017

Spun out of #2687, regression caused by #2669

Steps to repro:

1.Run test_sg_sdk_interop_shared_docs[sync_gateway_default_functional_tests-1-1000] against commit 85f79d0:

$ pytest -s --xattrs --mode=cc --server-version=5.0.0-3193 \
--sync-gateway-version=85f79d0f05ab63b20a5af62f703f128ce317ade5 \
-k "test_sg_sdk_interop_shared_docs[sync_gateway_default_functional_tests-1-1000]"  \ 
testsuites/syncgateway/functional/tests/

Pause python interpreter after updates, before deletes.

Using curl, try to delete latest rev:

curl -X DELETE http://192.168.33.11:4985/db/doc_set_one_0?rev=1930-b847c22efcc197ec966475261fb518a5

Get error:

{"error":"Internal Server Error","reason":"Internal error: WriteUpdateWithXattr() not able to find revision (1931-c46c29586616e553b3fdd640c06b0604) in history of doc: \u0026{syncData:{CurrentRev:1931-c46c29586616e553b3fdd640c06b0604 NewestRev: Flags:1 Sequence:4965 UnusedSequences:[] RecentSequences:[4849 4850 4853 4855 4856 4857 4859 4860 4862 4866 4965] History:map[] Channels:map[shared:0xc42c50bbe0] Access:map[] RoleAccess:map[] Expiry:\u003cnil\u003e Cas:0x00009d3650f1cb14 TombstonedAt:1498557550 UpstreamCAS:\u003cnil\u003e UpstreamRev: TimeSaved:2017-06-27 05:59:10.667782544 -0400 EDT Deleted_OLD:false} body:map[_deleted:true] ID:doc_set_one_0 Cas:1498556627846758400}.  Cannot update doc."}tleyden_macbook:~ tleyden$
@tleyden tleyden added this to the 1.5.0 milestone Jun 28, 2017
@tleyden tleyden self-assigned this Jun 28, 2017
@tleyden
Copy link
Contributor Author

tleyden commented Jun 28, 2017

Note: cannot repro with higher revs_limit, seems related to rev pruning

@djpongh djpongh added the ready label Jun 28, 2017
@tleyden tleyden changed the title SG returns 500 error on deletes during functional test Xattrs: SG returns 500 error on deletes during functional test Jun 28, 2017
@tleyden
Copy link
Contributor Author

tleyden commented Jun 28, 2017

Reverting commit the rev pruning change (commit 4d4e4f2), the test passes. So it's confirmed to be caused by that commit.

@tleyden
Copy link
Contributor Author

tleyden commented Jun 28, 2017

Debugging into this sync gateway error message:

CRUD+: Did not update document "doc_set_one_0" w/ xattr: WriteUpdateWithXattr() not able to find revision (201-814e75b628c1932548b252a628c131b2) in history of doc: &{syncData:{CurrentRev:201-814e75b628c1932548b252a628c131b2 NewestRev: Flags:1 Sequence:458 UnusedSequences:[] RecentSequences:[433 437 440 441 443 444 445 449 450 451 454 455 456 457 458] History:map[] Channels:map[shared:0xc420ae1c60] Access:map[] RoleAccess:map[] Expiry:<nil> Cas:0x0000a34dd9fccb14 TombstonedAt:1498569449 UpstreamCAS:<nil> UpstreamRev: TimeSaved:2017-06-27 09:17:29.162515565 -0400 EDT Deleted_OLD:false} body:map[_deleted:true] ID:doc_set_one_0 Cas:1498569311271452672}.  Cannot update doc.

The doc.History is completely empty, which is why it can't find the revision.

In the log line directly above that error, I'm seeing:

2017-06-27T09:17:29.162-04:00 CRUD+: updateDoc("doc_set_one_0"): Pruned 61 old revisions

and digging into that I can see that the entire revtree is getting pruned away when it consists of only a single tombstoned/deleted branch:

Before revtree pruning

screen shot 2017-06-28 at 12 17 14 pm

After revtree pruning

After pruning there is no rev history whatsoever.

I would expect it to keep 60 revisions after the rev tree pruning, since revs_limit is currently set to 60 in the config.

@tleyden
Copy link
Contributor Author

tleyden commented Jun 28, 2017

I just pushed the following changes up to the feature/issue_2695_sg_returns_500_err_delete branch:

Going to clean up the changes and push up a PR.

@tleyden tleyden changed the title Xattrs: SG returns 500 error on deletes during functional test Rev pruning algorithm deletes entire revtree if only branch is a tombstoned branch Jun 28, 2017
@djpongh djpongh added the review label Jun 28, 2017
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

3 participants