From: Jérémie Galarneau Date: Fri, 26 Jun 2020 22:40:12 +0000 (-0400) Subject: Fix: stream intersection fails on snapshot of cleared session X-Git-Tag: v2.13.0-rc1~597 X-Git-Url: https://git.lttng.org/?a=commitdiff_plain;ds=sidebyside;h=04ed9e10dfa0b3c88d4a7abe9fa59b8e03b7e49a;hp=04ed9e10dfa0b3c88d4a7abe9fa59b8e03b7e49a;p=lttng-tools.git Fix: stream intersection fails on snapshot of cleared session Observed issue ============== In the following scenario: lttng create --snapshot lttng enable-event -u -a lttng start taskset -c 0 lttng clear taskset -c 0 lttng snapshot record lttng destroy When using the stream-intersection mode, babetrace complains that the time range for the intersection is invalid since the begin timestamp is after the end timestamp. This is caused by the presence of "inactive" streams for which no events are recorded between the clear action and the recording of the snapshot. These streams have a begin timestamp roughly equal to the moment when the snapshot was taken (i.e. the end timestamp). Babeltrace, in stream-intersection mode, attempts to use the latest beginning timestamp of all streams as the start of the intersection and the earliest end timestamp as the end boundary. Path │File size │Packets │Timestamp: beginning │Timestamp: end │ snapshot-1-20200622-212617-1/ust/uid/1000/64-bit/channel0_0 │ 4.000 KiB│ 1│2020-06-22 21:26:01.903685878│2020-06-22 21:26:17.630456312│ snapshot-1-20200622-212617-1/ust/uid/1000/64-bit/channel0_1 │ 4.000 KiB│ 1│2020-06-22 21:26:17.630909310│2020-06-22 21:26:17.630909310│ snapshot-1-20200622-212617-1/ust/uid/1000/64-bit/channel0_2 │ 4.000 KiB│ 1│2020-06-22 21:26:17.631295033│2020-06-22 21:26:17.631295033│ snapshot-1-20200622-212617-1/ust/uid/1000/64-bit/channel0_3 │ 4.000 KiB│ 1│2020-06-22 21:26:17.631673614│2020-06-22 21:26:17.631673614│ Cause ===== The packet beginning timestamps of the buffers are initialized on creation (on the first "start" of a tracing session). When a "clear" is performed on a session, all open packets are closed and the existing contents are purged. If a stream is inactive, it is possible for no packet to be "opened" until a snapshot of the tracing session is recorded. Solution ======== A new consumer command, "open channel packets" is added. This command performs a "flush empty" operation on all streams of a channel. This command is invoked after a clear (after the tracing is re-started) and on start. This ensures that streams are opened as soon as possible after a clear, a rotation, or a session start. Known drawbacks =============== In the case of an inactive stream, this results an extra empty packet at the beginning of the inactive streams (typically 4kB) in the snapshots. In the case of an active stream, this change will cause the first packet to be empty or contain few events. If the stream is active enough to wrap-around, that empty packet will simply be overwritten. Signed-off-by: Jérémie Galarneau Change-Id: I19b5c630fa8bddfb13c3c10f86c6cc9dc4990b08 ---