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

Large Number Handled Incorrectly #3783

Closed
borrrden opened this issue Oct 5, 2018 · 3 comments

Comments

@borrrden
Copy link
Member

commented Oct 5, 2018

Sync Gateway version

2.1.0(121;a036bd8)

Operating system

Either Windows 10 or macOS High Sierra (probably doesn't matter)

Config file

Unused. Just specified --interface 0.0.0.0:4984

Log output

2018-10-05T10:23:54.170+09:00 [INF] HTTP: #18: PUT /sync_gateway/test (as GUEST)

Expected behavior

The number is stored correctly

Actual behavior

An alternate number is somehow inserted

Steps to reproduce

  1. Start Sync Gateway
  2. Send a PUT request for a document with the following body: {"number":9223372036854775807}
  3. GET the document, and notice that the number is instead 9223372036854776000
@borrrden

This comment has been minimized.

Copy link
Member Author

commented Oct 5, 2018

Wow looks like this issue has been around for a long time -> https://grokbase.com/t/couchdb/user/09b7nam3h0/silent-corruption-of-large-numbers/oldest

@adamcfraser

This comment has been minimized.

Copy link
Contributor

commented Oct 5, 2018

Would be interested to know whether you see this when running w/ xattrs enabled (shared bucket access) - we do a bit less document rewriting when we don't need to inject _sync metadata into the doc.

@adamcfraser

This comment has been minimized.

Copy link
Contributor

commented Oct 5, 2018

Verified this behaviour w/ both xattrs and non-xattrs. Issue occurs during JSON unmarshalling - the json decoder isn't currently setting UseNumber (to preserve large integers that otherwise get converted to float).

Could review all places that currently unmarshal documents and ensure decoder w/ UseNumber is applied.

The preferred approach is to also preserve raw document bytes whenever possible (particularly when using shared bucket access, where document mutations for _sync metadata aren't required).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.