Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-9178

Timestamp does not round trip correctly in V8 Javascript shell

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Critical - P2 Critical - P2
    • None
    • Affects Version/s: None
    • Component/s: JavaScript
    • None
    • ALL
    • Hide

      Spidermonkey (correct)

      > interpreterVersion()
      SpiderMonkey 1.7
      > db.ts.remove()
      > db.ts.insert({ ts : Timestamp(5,10) })
      > var ts = db.ts.findOne().ts
      > ts
      Timestamp(5, 10)
      > ts.t
      5
      > ts.i
      10
      > assert.eq(ts, Timestamp(5,10))
      >
      

      V8 (old/incorrect)

      > interpreterVersion()
      V8 3.12.19
      > db.ts.remove()
      > db.ts.insert({ ts : Timestamp(5,10) })
      > var ts = db.ts.findOne().ts
      > ts
      { "t" : 5, "i" : 10 }
      > ts.i
      10
      > ts.t
      5
      > assert.eq(ts, Timestamp(5,10))
      assert: [{ "t" : 5, "i" : 10 }] != [Timestamp(5, 10)] are not equal : undefined
      Error: Printing Stack Trace
          at printStackTrace (src/mongo/shell/utils.js:37:15)
          at doassert (src/mongo/shell/assert.js:6:5)
          at Function.assert.eq (src/mongo/shell/assert.js:32:5)
          at (shell):1:8
      Fri Mar 29 13:01:50.621 JavaScript execution failed: [{ "t" : 5, "i" : 10 }] != [Timestamp(5, 10)] are not equal : undefined at src/mongo/shell/assert.js:L7
      >
      
      Show
      Spidermonkey (correct) > interpreterVersion() SpiderMonkey 1.7 > db.ts.remove() > db.ts.insert({ ts : Timestamp(5,10) }) > var ts = db.ts.findOne().ts > ts Timestamp(5, 10) > ts.t 5 > ts.i 10 > assert .eq(ts, Timestamp(5,10)) > V8 (old/incorrect) > interpreterVersion() V8 3.12.19 > db.ts.remove() > db.ts.insert({ ts : Timestamp(5,10) }) > var ts = db.ts.findOne().ts > ts { "t" : 5, "i" : 10 } > ts.i 10 > ts.t 5 > assert .eq(ts, Timestamp(5,10)) assert : [{ "t" : 5, "i" : 10 }] != [Timestamp(5, 10)] are not equal : undefined Error: Printing Stack Trace at printStackTrace (src/mongo/shell/utils.js:37:15) at doassert (src/mongo/shell/ assert .js:6:5) at Function. assert .eq (src/mongo/shell/ assert .js:32:5) at (shell):1:8 Fri Mar 29 13:01:50.621 JavaScript execution failed: [{ "t" : 5, "i" : 10 }] != [Timestamp(5, 10)] are not equal : undefined at src/mongo/shell/ assert .js:L7 >

      A Timestamp inserted in the V8 shell using the constructor comes out as an ordinary object instead of a Timestamp.

      According to http://docs.mongodb.org/manual/core/document/#timestamps, this was changed in 2.1, but apparently only in Spidermonkey.

            Assignee:
            Unassigned Unassigned
            Reporter:
            sverch Shaun Verch
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: