From: Jérémie Galarneau Date: Fri, 12 Oct 2018 22:05:10 +0000 (-0400) Subject: relayd: keep track of prev_index_seq in relayd_stream X-Git-Tag: v2.11.0-rc2~198 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=1d3365cb3074a6dfac9648a65f10457a8c5d5d5b;p=lttng-tools.git relayd: keep track of prev_index_seq in relayd_stream The rotation and data pending checks are only performed on the sequence number of the received data. However, it is expected that the index of the stream (when applicable) has been written to disk when those checks say that their respective operations have completed. This patch only introduces a new 'prev_index_seq' position that is updated when an index is flushed to disk. A follow-up fix addresses the issue mentioned above. Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng-relayd/main.c b/src/bin/lttng-relayd/main.c index 5f56ba9b3..92f9a5600 100644 --- a/src/bin/lttng-relayd/main.c +++ b/src/bin/lttng-relayd/main.c @@ -2314,6 +2314,7 @@ static int relay_recv_index(const struct lttcomm_relayd_hdr *recv_hdr, tracefile_array_commit_seq(stream->tfa); stream->index_received_seqcount++; stream->pos_after_last_complete_data_index += index->total_size; + stream->prev_index_seq = index_info.net_seq_num; } else if (ret > 0) { /* no flush. */ ret = 0; @@ -3482,6 +3483,7 @@ static enum relay_connection_status relay_process_data_receive_payload( if (index_flushed) { stream->pos_after_last_complete_data_index = stream->tracefile_size_current; + stream->prev_index_seq = state->header.net_seq_num; } stream->prev_seq = state->header.net_seq_num; diff --git a/src/bin/lttng-relayd/stream.c b/src/bin/lttng-relayd/stream.c index 326ec4bf2..0ababf28d 100644 --- a/src/bin/lttng-relayd/stream.c +++ b/src/bin/lttng-relayd/stream.c @@ -83,6 +83,7 @@ struct relay_stream *stream_create(struct ctf_trace *trace, stream->stream_handle = stream_handle; stream->prev_seq = -1ULL; + stream->prev_index_seq = -1ULL; stream->last_net_seq_num = -1ULL; stream->ctf_stream_id = -1ULL; stream->tracefile_size = tracefile_size; diff --git a/src/bin/lttng-relayd/stream.h b/src/bin/lttng-relayd/stream.h index fb3e1ed68..151ae25c1 100644 --- a/src/bin/lttng-relayd/stream.h +++ b/src/bin/lttng-relayd/stream.h @@ -53,6 +53,8 @@ struct relay_stream { */ pthread_mutex_t lock; uint64_t prev_seq; /* previous data sequence number encountered. */ + /* previous index sequence number written to disk. */ + uint64_t prev_index_seq; uint64_t last_net_seq_num; /* seq num to encounter before closing. */ /* FD on which to write the stream data. */