Improve error logged when there's an exception applying ops #45
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.
We're still getting intermittent "Deleted string does not match" errors despite some of the other fixes applied, hoping that just logging the strings attempted to be deleted will reveal the problem.
To test (assuming starting from a blank slate):
Now we need to create a json type document with a text type subdocument, insert a string, then give it a bad delete op:
Create a document
curl -X PUT -H 'Content-Type: application/json' -d '{"type": "json"}' http://localhost:9000/doc/test
Post an object insert op to insert an empty object to create a json document type
curl -X POST -H 'Content-Type: application/json' -d '[{ "p": [], "oi": {} }]' http://localhost:9000/doc/test?v=0
Object insert on the key "test", inserting an empty string to create a text subdocument within the json document
curl -X POST -H 'Content-Type: application/json' -d '[{ "p": ["test"], "oi": "" }]' http://localhost:9000/doc/test?v=1
String insert on the text subdocument
curl -X POST -H 'Content-Type: application/json' -d '[{ "p": ["test", 0], "si": "foo bar" }]' http://localhost:9000/doc/test?v=2
At this point do a GET on the document just to sanity check it's as expected:
curl http://localhost:9000/doc/test
Should return
{"test":"foo bar"}
Now give it a bad delete operation to trigger the exception.
We want to delete from the last 'o' in foo to the 'a' in bar to send up with "for", but give it some bogus delete text
curl -X POST -H 'Content-Type: application/json' -d '[{ "p": ["test", 2], "sd": "xxxx" }]' http://localhost:9000/doc/test?v=3
This should raise an error
test Error: Deleted string does not match (1: "o ba" 2: "xxxx")
Now give it a properly formed delete op
curl -X POST -H 'Content-Type: application/json' -d '[{ "p": ["test", 2], "sd": "o ba" }]' http://localhost:9000/doc/test?v=3
GET the document again
curl http://localhost:9000/doc/test
The subdocument should only contain "for"
{"test":"for"}