Why dump_historic_ops misses old slow requests in Ceph
dump_historic_ops keeps at most 20 finished ops from the last 600 seconds by default. Defaults, what is dropped first, and how dump_historic_slow_ops differs.
$ ceph daemon osd.0 dump_historic_opsIf the slow request you are looking for is missing from that output, it has probably been pushed out of the history. On OSDs and MDS daemons dump_historic_ops keeps finished requests for 600 seconds and at most 20 of them by default. Past either limit, they are dropped.
[1] Check the defaults. The table below was the same in the Reef 18.2.4 and Squid 19.2.3 option definitions.
| Option | Default | Meaning |
|---|---|---|
osd_op_history_size | 20 | Maximum number of completed ops to track |
osd_op_history_duration | 600 | Oldest completed op to track (seconds) |
osd_op_history_slow_op_size | 20 | Maximum number of slow ops to track |
osd_op_history_slow_op_threshold | 10 | Ops that took at least this many seconds are recorded as slow |
mds_op_history_size / _duration / _slow_op_size / _slow_op_threshold | 20 / 600 / 20 / 10 | The same four on the MDS |
Sources: [OSD options, global.yaml.in L3297-L3320](https://github.com/ceph/ceph/blob/v19.2.3/src/common/options/global.yaml.in#L3297-L3320) (Reef L3242-L3265) and [MDS options, mds.yaml.in L1236-L1270](https://github.com/ceph/ceph/blob/v19.2.3/src/common/options/mds.yaml.in#L1236-L1270) (Reef L1152-L1185). Read the live values like this.
$ ceph config get osd osd_op_history_size$ ceph config get osd osd_op_history_duration$ ceph config show osd.0 osd_op_history_size[2] Know what is dropped. A finished op is added to the history, and cleanup does two things. It first removes ops that arrived more than 600 seconds ago. Then, while there are more than 20, it removes the op with the shortest duration ([TrackedOp.cc L83-L121](https://github.com/ceph/ceph/blob/v19.2.3/src/common/TrackedOp.cc#L83-L121)). So:
- An op older than ten minutes (the default) is gone.
- Inside those ten minutes, past 20 entries only the 20 longest ops stay and shorter ones are pushed out.
- Cleanup runs when a new op is recorded and when you dump (L123-L128).
On a busy daemon a 5-9 second op can be displaced by longer ones, and anything slow from last night is not there in the morning. This is read from the code; how many ops get displaced on a real cluster was not checked.
[3] Pick the dump order. dump_historic_ops lists ops by arrival, dump_historic_ops_by_duration by longest first ([TrackedOp.cc L123-L148](https://github.com/ceph/ceph/blob/v19.2.3/src/common/TrackedOp.cc#L123-L148)). The output begins with the daemon's own size and duration values, so the active settings are visible at once.
$ ceph daemon osd.0 dump_historic_ops_by_duration$ ceph daemon mds.a dump_historic_ops_by_duration[4] On OSDs, use dump_historic_slow_ops. It shows a separate list holding only ops that took osd_op_history_slow_op_threshold (default 10 seconds) or more ([OSD.cc L2791-L2793](https://github.com/ceph/ceph/blob/v19.2.3/src/osd/OSD.cc#L2791-L2793), [TrackedOp.cc L201-L229](https://github.com/ceph/ceph/blob/v19.2.3/src/common/TrackedOp.cc#L201-L229)). Two differences. This list does not expire by time; it is trimmed only by count (osd_op_history_slow_op_size, default 20), oldest arrival first. Ops under 10 seconds never enter it.
$ ceph daemon osd.0 dump_historic_slow_opsThe MDS has no such command. Only dump_historic_ops and dump_historic_ops_by_duration are registered on its admin socket ([MDSDaemon.cc L299-L306](https://github.com/ceph/ceph/blob/v19.2.3/src/mds/MDSDaemon.cc#L299-L306); the handling branch is [MDSRank.cc L2803-L2810](https://github.com/ceph/ceph/blob/v19.2.3/src/mds/MDSRank.cc#L2803-L2810)). The two MDS _slow_op_* options in the table exist, but no command dumps that slow list. On the MDS use dump_historic_ops_by_duration.
[5] Decide whether to raise the limits. The history holds finished op objects in sets ordered by arrival and by duration ([TrackedOp.cc L83-L121](https://github.com/ceph/ceph/blob/v19.2.3/src/common/TrackedOp.cc#L83-L121)), so larger limits can use more memory, but the option definitions and docs give no figure and how much was not checked. If you need it, try one daemon first and keep the undo handy.
$ ceph config set osd.0 osd_op_history_size 100$ ceph config rm osd.0 osd_op_history_sizeThe OSD passes new osd_op_history_size and osd_op_history_duration values to its op tracker as soon as they change, so no OSD restart is needed ([OSD.cc L9972-L9975](https://github.com/ceph/ceph/blob/v19.2.3/src/osd/OSD.cc#L9972-L9975)). Confirm with the size value at the top of the dump in [3].
[6] The defaults explain why you need continuous collection. The history is the last ten minutes and at most 20 ops. If a person types the command after a problem is reported, the entries may already be gone. To investigate later, something has to save the dump to a file while the slow ops are happening, and dump_historic_ops is only meaningful inside that window. How to read the event list of an op is in the Debugging Slow Requests section of the OSD troubleshooting doc.