endSessions does not end syntactically valid session ids and does not report this as a failure

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Won't Fix
    • Priority: Minor - P4
    • None
    • Affects Version/s: 4.1.6
    • Component/s: None
    • None
    • ALL
    • Sharding 2019-03-11
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      I am attempting to end outstanding sessions, using https://docs.mongodb.com/manual/reference/operator/aggregation/listLocalSessions/ and https://docs.mongodb.com/v3.6/reference/command/endSessions/. To this end I have the following code:

          sessions = client.database.command(
            aggregate: 1,
            pipeline: [{'$listLocalSessions' => {}}],
            cursor: {}
          ).first['cursor']['firstBatch']
          # https://docs.mongodb.com/v3.6/reference/command/endSessions/
          session_ids = sessions.map do |session|
            session['_id']
          end
          session_ids.each do |session_id|
            rv = client.database.command(endSessions: [session_id])
          end
      

      The result of endSessions is as follows:

      (byebug) p rv.first
      {"ok"=>1.0, "$clusterTime"=>{"clusterTime"=>#<BSON::Timestamp:0x00005619179b1708 @seconds=1550452237, @increment=1>, "signature"=>{"hash"=><BSON::Binary:0x47332885105140 type=generic data=0x0000000000000000...>, "keyId"=>0}}, "operationTime"=>#<BSON::Timestamp:0x00005619179b12d0 @seconds=1550452237, @increment=1>}
      

      There's an

      {ok:1}

      in there, OK. Now if I kill the same session again I still get the same result:

      (byebug) rv = client.database.command(endSessions: [session_id])
      #<Mongo::Operation::Result:0x47332885140160 documents=[{"ok"=>1.0, "$clusterTime"=>{"clusterTime"=>#<BSON::Timestamp:0x00005619179b1708 @seconds=1550452237, @increment=1>, "signature"=>{"hash"=><BSON::Binary:0x47332885105140 type=generic data=0x0000000000000000...>, "keyId"=>0}}, "operationTime"=>#<BSON::Timestamp:0x00005619179b12d0 @seconds=1550452237, @increment=1>}]>
      (byebug) p rv.first
      {"ok"=>1.0, "$clusterTime"=>{"clusterTime"=>#<BSON::Timestamp:0x00005619179b1708 @seconds=1550452237, @increment=1>, "signature"=>{"hash"=><BSON::Binary:0x47332885105140 type=generic data=0x0000000000000000...>, "keyId"=>0}}, "operationTime"=>#<BSON::Timestamp:0x00005619179b12d0 @seconds=1550452237, @increment=1>}
      

      If I execute listlocalsessions after running the code to end the sessions, I still get the same number of sessions outstanding. At this point I cannot tell if I am passing the session ids wrong or the server chooses to ignore my session ending requests.

      https://docs.mongodb.com/v3.6/reference/command/endSessions/ says:

      > MongoDB concatenates each of the specified UUIDs with the hash of the authenticated user credentials to identify the user's sessions to end. If the user has no session that match, the endSessions has no effect.

      How do I figure out if this applies? I am querying the sessions with the same client and credentials and database as the ones I am using for endSessions. If I need to query them in a different manner how do I do that?

      To summarize:

      1. endSessions should report when it is unable to end one or more of the passed sessions, and ideally with a reason why.
      2. Ending nonexistent (or already ended) sessions should be indicated in some fashion, OR there should be a way to tell whether a session is ended when querying it.

            Assignee:
            Blake Oler
            Reporter:
            Oleg Pudeyev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: