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

ftdc_connection_reuse.js can unsafely attempt to read missing keys from FTDC BSON

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 7.0.0-rc0, 7.1.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Service Arch
    • Fully Compatible
    • ALL
    • v7.0
    • Service Arch 2023-04-17
    • 25

      In it's  getDiagnosticData helper, ftdc_connection_reuse.js pulls FTDC twice from the server; once to make sure a specific sub-document (the connPoolStats pool entry for a NITL pool) is present in the returned BSON, and once again to actually fetch the data to provide for the rest of the test to use after it determines that sub-document is present.

      However, the FTDC document returned by the server can change between the two pulls, if the FTDC loop runs in between them. In the following ordering of events: 

      • FTDC loop runs, collects "A" as most recent document; A contains the sub-document the test searches for 
      • Test executes dropConnections
      • Test does first pull; sees "A", which contains the sub-doc it looks for
      • FTDC loop runs on server, collects "B" as most recent document. B no longer contains the sub-document (because the drop-connections eliminated the NITL pool so it no longer appears in connpoolstats). 
      • Test does second pull; sees "B", which no longer contains the sub-doc for that NITL pool.

      The test will attempt to access a key in the BSON that doesn't exist: https://github.com/mongodb/mongo/blob/861164c8a2d50c1b99111f30359c4b5826623fa7/jstests/noPassthrough/ftdc_connection_reuse.js#L37 resulting in it returning "undefined" value that is subsequently attempted to be unsafely read-into later in the test (i.e. here). 

      To fix we should make sure the FTDC that is checked for NITL-pool-presence is the same blob that is returned to the rest of the test.

      We should also consider ensuring that the dropConnections has been viewed by the FTDC collector before proceeding with the test, to ensure that we don't need to wait for it to update the view an additional time (once to see the dropConnections, and once again to see the new data we expect after doing more work). But this is optional, as the test should keep retrying to pull more data until the expected state is seen. 

            Assignee:
            jason.chan@mongodb.com Jason Chan
            Reporter:
            george.wangensteen@mongodb.com George Wangensteen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: