[SERVER-53241] Always log createIndexes command to capture index definition Created: 04/Dec/20  Updated: 18/Aug/21  Resolved: 18/Aug/21

Status: Closed
Project: Core Server
Component/s: Logging
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: Katya Kamenieva Assignee: Dan Larkin-York
Resolution: Done Votes: 1
Labels: metrics
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
Sprint: Execution Team 2021-08-23
Participants:

 Description   

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
    }
}

 



 Comments   
Comment by Githook User [ 18/Aug/21 ]

Author:

{'name': 'Dan Larkin-York', 'email': 'dan.larkin-york@mongodb.com', 'username': 'dhly-etc'}

Message: SERVER-53241 Always log createIndexes command to capture index definition
Branch: master
https://github.com/mongodb/mongo/commit/01fb3fac6dbf5a6566e0ce6cf5218d4274df19f1

Comment by Bruce Lucas (Inactive) [ 07/Dec/20 ]

An alternative (or addition) to this might be to log complete details when the createIndexes command is started. This has the advantage that if something goes wrong during the index build, say for example a crash due to resource consumption, we will know what the offending index is.

Generated at Thu Feb 08 05:30:20 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.