Uploaded image for project: 'MongoDB Shell'
  1. MongoDB Shell
  2. MONGOSH-946

Add functionality to mongosh to decode a resume token

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 1.0.6
    • Affects Version/s: None
    • Component/s: snippets
    • None
    • 3
    • Iteration Johannesburg
    • Needed
    • Hide

      We provide a snippet (see DOCSP-16500 for details on snippets, still open atm) for decoding resume tokens. Users can run `snippet install resumetoken` and then use the `decodeResumeToken()` method on a change stream resume token; for example:

      > cs = db.test.watch()
      ChangeStreamCursor on test
      > token = cs.getResumeToken()
      { _data: '82612F69A2000000022B0229296E04' }
      // Either apply decodeResumeToken() to the token object...
      > decodeResumeToken(token)
      {
        timestamp: new Timestamp({ t: 1630497186, i: 2 }),
        version: 1,
        tokenType: 0,
        txnOpIndex: 0,
        fromInvalidate: false,
        uuid: undefined,
        documentKey: undefined
      }
      // ... or to the raw hex string
      > decodeResumeToken('82612F69A2000000022B0229296E04')
      {
        timestamp: new Timestamp({ t: 1630497186, i: 2 }),
        /* ... */
      }
      

      I don’t know if it’s worth mentioning, but users who have npm installed (not necessarily mongosh) can also run `npx mongodb-resumetoken-decoder <hex string>` directly from the command line.

      Show
      We provide a snippet (see DOCSP-16500 for details on snippets, still open atm) for decoding resume tokens. Users can run `snippet install resumetoken` and then use the `decodeResumeToken()` method on a change stream resume token; for example: > cs = db.test.watch() ChangeStreamCursor on test > token = cs.getResumeToken() { _data: '82612F69A2000000022B0229296E04' } // Either apply decodeResumeToken() to the token object... > decodeResumeToken(token) { timestamp: new Timestamp({ t: 1630497186, i: 2 }), version: 1, tokenType: 0, txnOpIndex: 0, fromInvalidate: false , uuid: undefined, documentKey: undefined } // ... or to the raw hex string > decodeResumeToken( '82612F69A2000000022B0229296E04' ) { timestamp: new Timestamp({ t: 1630497186, i: 2 }), /* ... */ } I don’t know if it’s worth mentioning, but users who have npm installed (not necessarily mongosh) can also run `npx mongodb-resumetoken-decoder <hex string>` directly from the command line.

      We had a request in SERVER-55978 to add something in the legacy shell to decode a resume token. It sounds like we are moving to prefer mongosh instead, so I've filed this ticket in its stead.

            Assignee:
            anna.henningsen@mongodb.com Anna Henningsen
            Reporter:
            kyle.suarez@mongodb.com Kyle Suarez
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: