ExportXMLWordPrintableJSON

    • 2
    • None
    • Hide

      Review the ticket description for general accuracy and completeness

      • Bug - Confirm that the bug still exists
      • Task / Feature / Improvement - Ensure every section of the template is filled out and makes sense
      • Build failure - Investigate and confirm the cause of the build failure
      • Spec change - Check whether any more recent changes have been made to the spec that might affect the implementation requirements

      What is the expected behavior?

      • What do the official driver or server docs currently say about this functionality?
        • What should they say?
          • If revisions or additions are needed, mark the ticket as docs changes needed and fill out the doc changes form
      • What do our api or readme docs currently say about this functionality?
        • Lists inherited Long methods
        • What should they say?
          • Should not list inherited Long methods
        • Capture any revisions or additions in the ticket documentation AC
          • Done
      • If applicable, what does the common drivers spec say? (Note: your kickoff partner should independently review the spec)
        • Are any clarifications or revisions needed?
      • If applicable, what do other drivers do?
        • If there is no common spec, is a common spec needed?
      • What should the behavior be?
        • Should not inherit from Long
      • Update the ticket description and implementation requirements as needed
        • Done

      Review and address any unknowns explicitly called out in the ticket

      • Done

      What will be the impact on users?

      • Who will be impacted?
        • Done
      • Why might users care about this change?
        • Done
      • Capture relevant detail in the "User Impact" section of the ticket description
        • Done

      What will be the impact on any downstream projects? (e.g., shell, mongoose)

      • Update follow up requirements and create subtasks for follow up or coordination actions
        • Done

      What variables affect the feature in question?

      • Server versions
      • Deployment types
      • Auth settings
      • Server and client configuration options
      • Specific apis / api options
      • Runtime or bundler settings
      • Special sequences of operations
      • Any other special conditions

      How should all the identified variables be tested?

      • Identify happy path and error case combinations of variables
        • Given [variables], when [action is performed], [feature] should [behave in the expected way]
      • How will we achieve the necessary coverage for these cases?
        • Automated spec tests?
          • Are there test runner changes required?
          • How up to date are our current tests and runners?
        • New integration or prose tests?
        • Unit tests?
          • Yes, see AC
      • Will we need to modify any existing tests?
        • No
      • Is there technical debt that will affect the implementation of new or existing tests?
        • No
      • Do we have the necessary tooling infrastructure already in place for any new tests?
        • Yes
      • Update test requirements on the ticket to reflect reality
        • Done
      • Create subtasks for any testing groundwork that can happen independently of the implementation

      What is the scope of the code changes?

      • List the code bases and the areas of each code base that will need changes
        • js-bson, src/timestamp.ts
        • note that there are uses in the driver of Long methods on Timestamps, but these uses will be handled in NODE-5242
      • Is there technical debt in any of these areas that will affect the implementation?
      • Identify any existing adjacent functionality that could be impacted by these changes
        • Is there sufficient existing test coverage for the adjacent functionality?
          • Update ticket test AC and create subtask(s) to cover existing functionality if coverage is missing
      • If multiple libraries are affected, determine the order in which changes need to go in
      • Create subtasks for the implementation (at least one per affected codebase)

      What is the expected impact on performance?

      • Unsure, but should not be significant
      • Do we have existing performance coverage for the affected areas?
        • yes, in the driver
      • Do we need to add new coverage?
        • No
        • Update ticket test AC and create subtask(s) as needed

      Consider backport requirements

      • Should this be backported?
        • No; breaking change
      • What would be the cost of a backport?

      Is the metadata of this ticket accurate and complete?

      • Double check the acceptance criteria to ensure it accurately captures the expected behavior, test, and follow-up requirements
        • Done
      • Double check the documentation requirements
        • Done
      • Double check the task breakdown to ensure it covers all actionable items in the ticket AC
        • Done
      Show
      Review the ticket description for general accuracy and completeness Bug - Confirm that the bug still exists Task / Feature / Improvement - Ensure every section of the template is filled out and makes sense Build failure - Investigate and confirm the cause of the build failure Spec change - Check whether any more recent changes have been made to the spec that might affect the implementation requirements What is the expected behavior? What do the official driver or server docs currently say about this functionality? What should they say? If revisions or additions are needed, mark the ticket as docs changes needed and fill out the doc changes form What do our api or readme docs currently say about this functionality? Lists inherited Long methods What should they say? Should not list inherited Long methods Capture any revisions or additions in the ticket documentation AC Done If applicable, what does the common drivers spec say? (Note: your kickoff partner should independently review the spec) Are any clarifications or revisions needed? If applicable, what do other drivers do? If there is no common spec, is a common spec needed? What should the behavior be? Should not inherit from Long Update the ticket description and implementation requirements as needed Done Review and address any unknowns explicitly called out in the ticket Done What will be the impact on users? Who will be impacted? Done Why might users care about this change? Done Capture relevant detail in the "User Impact" section of the ticket description Done What will be the impact on any downstream projects? (e.g., shell, mongoose) Update follow up requirements and create subtasks for follow up or coordination actions Done What variables affect the feature in question? Server versions Deployment types Auth settings Server and client configuration options Specific apis / api options Runtime or bundler settings Special sequences of operations Any other special conditions How should all the identified variables be tested? Identify happy path and error case combinations of variables Given [variables] , when [action is performed] , [feature] should [behave in the expected way] How will we achieve the necessary coverage for these cases? Automated spec tests? Are there test runner changes required? How up to date are our current tests and runners? New integration or prose tests? Unit tests? Yes, see AC Will we need to modify any existing tests? No Is there technical debt that will affect the implementation of new or existing tests? No Do we have the necessary tooling infrastructure already in place for any new tests? Yes Update test requirements on the ticket to reflect reality Done Create subtasks for any testing groundwork that can happen independently of the implementation What is the scope of the code changes? List the code bases and the areas of each code base that will need changes js-bson, src/timestamp.ts note that there are uses in the driver of Long methods on Timestamps, but these uses will be handled in NODE-5242 Is there technical debt in any of these areas that will affect the implementation? Identify any existing adjacent functionality that could be impacted by these changes Is there sufficient existing test coverage for the adjacent functionality? Update ticket test AC and create subtask(s) to cover existing functionality if coverage is missing If multiple libraries are affected, determine the order in which changes need to go in Create subtasks for the implementation (at least one per affected codebase) What is the expected impact on performance? Unsure, but should not be significant Do we have existing performance coverage for the affected areas? yes, in the driver Do we need to add new coverage? No Update ticket test AC and create subtask(s) as needed Consider backport requirements Should this be backported? No; breaking change What would be the cost of a backport? Is the metadata of this ticket accurate and complete? Double check the acceptance criteria to ensure it accurately captures the expected behavior, test, and follow-up requirements Done Double check the documentation requirements Done Double check the task breakdown to ensure it covers all actionable items in the ticket AC Done
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?
    • None
    • None
    • None
    • None
    • None
    • None

      Timestamp extends Long, so it exposes the whole 64-bit integer API: arithmetic, bitwise ops, signedness, raw low/high. A BSON Timestamp is just two uint32s, t (seconds since epoch) and i (increment), and most of that API makes no sense for it. It also gives odd results, e.g. ts.add(...) returns a Long (NODE-4098).

      NODE-7069 (bson 7.3.0, js-bson #887) did the groundwork with no runtime changes. It split the inherited Long members into kept and deprecated (the kept ones are the TimestampKept allowlist in src/timestamp.ts), and also deprecated MAX_VALUE, fromInt, fromNumber and TimestampOverrides.

      This ticket is the breaking part for bson v8: drop the Long base class, remove what 7069 deprecated, keep the rest.

      The first attempt (js-bson #606, 2023) removed comparisons as well and was closed because ts1.greaterThan(ts2) had no good replacement. 7069 keeps comparisons, so that concern is resolved.

      Use Case

      As a user of the BSON library
      I want Timestamp to only expose what makes sense for a (t, i) pair
      So that I don't misuse it as a general 64-bit integer

      Unknowns

      1. Should comparison methods accept only Timestamp? Today they take string | number | Long | Timestamp via Long. Probably Timestamp only; the driver never compares against anything else.
      2. Should the constructor throw on a negative or larger-than-uint64 bigint? Today it silently wraps (new Timestamp(-1n) gives t = i = 0xffffffff). I'd throw. Signed Long input can keep being reinterpreted as unsigned bits.

      User Impact

      • Breaking. Everything deprecated in NODE-7069 is gone: arithmetic and bitwise ops, toNumber/toInt/toBytes*, getHighBits/getLowBits and their unsigned variants, low/high/unsigned, isZero, MAX_VALUE, fromInt, fromNumber, etc.
      • Long.isLong(ts) and ts instanceof Long become false.
      • Comparisons, toBigInt(), toString(), t, i, fromBits and fromString keep working.
      • Long methods no longer accept a Timestamp.

      Dependencies

      • NODE-7069 (done)
      • Ships with bson v8 (NODE-6999)
      • mongosh will break on upgrade: shell-api/src/helpers.ts duck-types Timestamps with 'getHighBits' in x, and shell-bson/src/shell-bson.ts re-exports fromInt, fromNumber and MAX_VALUE.
      • The driver only uses greaterThan and _bsontype on Timestamps, so it shouldn't need changes. Confirm during the v8 bump.

      Acceptance Criteria

      Implementation Requirements

      • Timestamp extends BSONValue instead of Long. Store t and i as two uint32 numbers behind read-only getters. No need to wrap a private Long, and this saves an allocation per Timestamp (every server response has $clusterTime and operationTime).
      • Remove everything in the DEPRECATED block of src/timestamp.ts, plus MAX_VALUE, fromInt, fromNumber, the TimestampOverrides, LongWithoutOverrides and TimestampKept types, and LongWithoutOverridesClass (including the exports in src/bson.ts).
      • Implement the kept members on Timestamp itself, with the same behavior as today (unsigned 64-bit order, i.e. compare t, then i):
        • compare, equals/eq, notEquals/neq/ne, lessThan/lt, lessThanOrEqual/lte/le, greaterThan/gt, greaterThanOrEqual/gte/ge
        • toBigInt() and toString(radix?), so toJSON() output stays the same
      • Add toLong() returning an unsigned Long, for anyone who was using the removed Long methods.
      • Keep fromBits, fromString, toJSON, toExtendedJSON, fromExtendedJSON, inspect, _bsontype and [bsonType].
      • Constructor keeps its current overloads, including new Timestamp(otherTimestamp).
      • Fix internal code that relies on the inheritance:
        • serializeLong in src/parser/serializer.ts calls getLowBits()/getHighBits() on Timestamps
        • BSON_TYPE_MAPPINGS.Timestamp in src/extended_json.ts reads o.low/o.high (keep low/high as a fallback for old duck-typed objects)
      • Remove Timestamp from Long method parameter types in src/long.ts, and throw a BSONError if one is passed at runtime. Without that, Long.fromValue reads the missing low/high as 0, and you get things like {{Long.ZERO.eq(new Timestamp( { t: 100, i: 5 }

        ))}} returning true.

      Testing Requirements

      • Unit tests for every kept or new member. Comparisons should cover a differing t, the same t with a differing i, equal values, and uint32 edges.
      • Constructor tests: rejects bad input (per Unknown 2), copies from another Timestamp, existing inputs still work.
      • Long methods throw when passed a Timestamp.
      • ts instanceof Long and Long.isLong(ts) are false.
      • Turn the NODE-7069 deprecation checks in test/types/bson.test-d.ts into property-doesn't-exist checks.
      • Rewrite existing tests that rely on unsigned/low/high/MAX_VALUE to use t/i. Everything else, BSON corpus included, passes unchanged.
      • Driver tests pass against the new bson. No regression in the bson benchmarks.

      Documentation Requirements

      • TBD

      Follow-Up Requirements

      • Give the mongosh team a heads up before bson v8 ships.

            Assignee:
            Sergey Zelenov
            Reporter:
            Matt Broadstone
            None
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: