Uploaded image for project: 'Couchbase Server'
  1. Couchbase Server
  2. MB-53923

CAS from couch_dbdump --json is incorrectly rounded to 2^53

    XMLWordPrintable

Details

    • 1

    Description

      couch_dbdump --json since MB-49817 (v7.1.0) outputs CAS as JSON number types.

      While the JSON library we use (nlohmann::json) has no problem with 64bit integers, other JSON libraries / tools (such as jq) do not correctly parse these large numbers and silently discard least-significant bits / round the value. For example, note the difference in displayed CAS value with and without piping the output of couch_dbdump to jq :

      install/bin/couch_dbdump --key  doc_key --json ../ns_server/data/n_0/data/default/997.couch.1 
      {"body":{"json":"maybe?"},"cas":1664543368459911168, ... <cut>
      

      vs

      install/bin/couch_dbdump --key doc_key --json ../ns_server/data/n_0/data/default/997.couch.1 | jq -c
      {"body":{"json":"maybe?"},"cas":1664543368459911200," ... <cut>
      

      The correct CAS value of 1664543368459911168 is mangled and is rounded to 1664543368459911200.

      In the specific case of jq this is a known bug and fixed in master, but is not fixed in the current latest release (1.6).

      To try to mitigate these kinds of problems in future, we should change couch_dbdump to represent CAS values as stings which will not be mangled.

      Attachments

        Issue Links

          For Gerrit Dashboard: MB-53923
          # Subject Branch Project Status CR V

          Activity

            People

              drigby Dave Rigby (Inactive)
              drigby Dave Rigby (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty