Fix: split index and data file rotation logic
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 12 Nov 2018 21:52:26 +0000 (16:52 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 12 Nov 2018 23:32:51 +0000 (18:32 -0500)
commitc6db3843828a8fbf08444a2bc4191291a4807936
tree0902d4a029d51b346d81f98a9b06b143379d0fca
parentb00e554eef4eec08eea1f245b82cf737db9547e6
Fix: split index and data file rotation logic

Issue
---

There is no guarantee that index and data positions (sequence numbers)
match at a given time as both are received on different sockets.

Currently, the relay determines whether or not it should rotate a
stream's data and index files based on the lowest sequence number
of both the data and index file.

When the data connection "lags" behind the control connection, index
entries received on the control connection that belong in the "next"
chunk are written to the "previous" chunk's index file.

While there is logic to ensure that trace data received after the
current rotation position is copied to the "previous" chunk when the
rotation is performed, the same is not true for the index file
rotation.

This is fine as it should not be needed. The consumerd <-> relayd
protocol ensures that a rotation command issued on a stream will
provide a rotation position that is either:
  - the stream's current position,
  - a position that will be reached in the future.

Then, the control connection will receive index entries that are
either <= to the rotation target sequence number.

Therefore, it is correct to check if an index file should be rotated
everytime an index entry is flushed and change the index output file
when the rotation position is reached.

Again, this is not true for the data connection as it would be
possible to receive a rotation command with a position that is
before the current data sequence number.

Solution
---

This change splits the logic to evaluate the moment at which a
rotation should be performed (changing the actual file to which data
is written) so that both index and data files are rotated
independently.

Hence, when an index is flushed, the relay will always evaluate
whether or not it should switch the index file to its new destination
(i.e. perform the rotation of the index).

The "data" reception logic remains mostly unchanged, except that
the trace sequence number is no longer used. Only the data stream's
position is considered to evaluate whether the data stream file
should be rotated.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-relayd/main.c
src/bin/lttng-relayd/stream.h
This page took 0.025375 seconds and 4 git commands to generate.