Fix: consumer: do not flush on transition from NULL chunk
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 12 Dec 2019 18:09:18 +0000 (13:09 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 20 Dec 2019 00:24:47 +0000 (19:24 -0500)
When transitioning from NULL chunk, do not flush streams, because
the consumer has nowhere to store the packets generated by this
flush.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ic92c035f6b1377849825527d0c9cc05a6b92ac38
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/common/consumer/consumer.c

index e27161e436cecce180b32ca31231ad35ee6b0f59..89d27a0d9ed8e32aa6511bc1b091a8bbc4881845 100644 (file)
@@ -4029,14 +4029,23 @@ int lttng_consumer_rotate_channel(struct lttng_consumer_channel *channel,
                }
 
                /*
-                * Active flush; has no effect if the production position
-                * is at a packet boundary.
+                * Do not flush an empty packet when rotating from a NULL trace
+                * chunk. The stream has no means to output data, and the prior
+                * rotation which rotated to NULL performed that side-effect already.
                 */
-               ret = consumer_flush_buffer(stream, 1);
-               if (ret < 0) {
-                       ERR("Failed to flush stream %" PRIu64 " during channel rotation",
-                                       stream->key);
-                       goto end_unlock_stream;
+               if (stream->trace_chunk) {
+                       /*
+                        * For metadata stream, do an active flush, which does not
+                        * produce empty packets. For data streams, empty-flush;
+                        * ensures we have at least one packet in each stream per trace
+                        * chunk, even if no data was produced.
+                        */
+                       ret = consumer_flush_buffer(stream, stream->metadata_flag ? 1 : 0);
+                       if (ret < 0) {
+                               ERR("Failed to flush stream %" PRIu64 " during channel rotation",
+                                               stream->key);
+                               goto end_unlock_stream;
+                       }
                }
 
                ret = lttng_consumer_take_snapshot(stream);
This page took 0.027182 seconds and 4 git commands to generate.