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

Always log createIndexes command to capture index definition

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Logging
    • Execution Team 2021-08-23

      Currently we always log entries about index build, but it only includes namespace and name of the index. The details of index definition will only be logged if command exceeds the slowms threshold, which likely won't happen for empty or small collections. 

      Unless the command is no-op, e.g. index already exists, log it unconditionally.

      Example of the entries to be logged:

      {
          "t": {
              "$date": "2020-12-01T16:32:23.066-05:00"
          },
          "s": "I",
          "c": "COMMAND",
          "id": 51803,
          "ctx": "conn5",
          "msg": "Slow query",
          "attr": {
              "type": "command",
              "ns": "test.log",
              "appName": "MongoDB Shell",
              "command": {
                  "createIndexes": "log",
                  "indexes": [
                      {
                          "key": {
                              "lastModifiedDate": 1.0
                          },
                          "name": "lastModifiedDate_1",
                          "expireAfterSeconds": 3600.0
                      }
                  ],
                  "lsid": {
                      "id": {
                          "$uuid": "dc5b96ce-8c46-47b6-82a2-311eab1f3892"
                      }
                  },
                  "$db": "test"
              },
              "numYields": 0,
              "reslen": 114,
              "locks": {
                  "ParallelBatchWriterMode": {
                      "acquireCount": {
                          "r": 3
                      }
                  },
                  "ReplicationStateTransition": {
                      "acquireCount": {
                          "w": 4
                      }
                  },
                  "Global": {
                      "acquireCount": {
                          "r": 2,
                          "w": 2
                      }
                  },
                  "Database": {
                      "acquireCount": {
                          "r": 2,
                          "w": 1
                      }
                  },
                  "Collection": {
                      "acquireCount": {
                          "r": 2,
                          "W": 1
                      }
                  },
                  "Mutex": {
                      "acquireCount": {
                          "r": 3
                      }
                  }
              },
              "flowControl": {
                  "acquireCount": 2,
                  "timeAcquiringMicros": 1
              },
              "storage": {},
              "protocol": "op_msg",
              "durationMillis": 33
          }
      },
      {
          "t": {
              "$date": "2020-12-03T16:47:32.256-05:00"
          },
          "s": "I",
          "c": "COMMAND",
          "id": 51803,
          "ctx": "conn6",
          "msg": "Slow query",
          "attr": {
              "type": "command",
              "ns": "test.geo1",
              "appName": "MongoDB Shell",
              "command": {
                  "createIndexes": "geo1",
                  "indexes": [
                      {
                          "key": {
                              "location": "2dsphere"
                          },
                          "name": "location_2dsphere"
                      }
                  ],
                  "lsid": {
                      "id": {
                          "$uuid": "f8611f64-ad09-4884-a6f6-58860c0809ff"
                      }
                  },
                  "$db": "test"
              },
              "numYields": 0,
              "reslen": 114,
              "locks": {
                  "ParallelBatchWriterMode": {
                      "acquireCount": {
                          "r": 3
                      }
                  },
                  "ReplicationStateTransition": {
                      "acquireCount": {
                          "w": 4
                      }
                  },
                  "Global": {
                      "acquireCount": {
                          "r": 2,
                          "w": 2
                      }
                  },
                  "Database": {
                      "acquireCount": {
                          "r": 2,
                          "w": 1
                      }
                  },
                  "Collection": {
                      "acquireCount": {
                          "r": 2,
                          "W": 1
                      }
                  },
                  "Mutex": {
                      "acquireCount": {
                          "r": 3
                      }
                  }
              },
              "flowControl": {
                  "acquireCount": 2,
                  "timeAcquiringMicros": 2
              },
              "storage": {},
              "protocol": "op_msg",
              "durationMillis": 30
          }
      }

       

            Assignee:
            dan.larkin-york@mongodb.com Dan Larkin-York
            Reporter:
            kateryna.kamenieva@mongodb.com Katya Kamenieva
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: