Fix: src.ctf.lttng-live: consider empty metadata packet as retry
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Mon, 13 Jul 2020 21:45:35 +0000 (17:45 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 25 Feb 2022 20:30:38 +0000 (15:30 -0500)
When clearing a live session, it's possible for the Relay to know that
metadata is available even though it has not yet received it from the
consumer.

In such cases, the relay will send a `LTTNG_VIEWER_METADATA_OK` reply
with a zero length metadata packet. The viewer needs to interpret that
as "please try again later". In fact, the viewer needs to keep
requesting metadata from the relay until it receives either a
`LTTNG_VIEWER_NO_NEW_METADATA` status or an error status.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ief33f1a43ec827e211a2f4f2ace623e9d3254246
Reviewed-on: https://review.lttng.org/c/babeltrace/+/7392

src/plugins/ctf/lttng-live/viewer-connection.c

index 0a3f5018435982d28f653959f93754ed0ff234d4..f21dc21ca8e0216dcd526d16e5b8c88c05796613 100644 (file)
@@ -1316,14 +1316,18 @@ enum lttng_live_get_one_metadata_status lttng_live_get_one_metadata_packet(
        }
 
        len = be64toh(rp.len);
-       BT_COMP_LOGD("Writing %" PRIu64" bytes to metadata", len);
-       if (len <= 0) {
-               BT_COMP_LOGE_APPEND_CAUSE(self_comp,
-                       "Erroneous response length");
-               status = LTTNG_LIVE_GET_ONE_METADATA_STATUS_ERROR;
-               goto end;
+       if (len == 0) {
+               /*
+                * We received a `LTTNG_VIEWER_METADATA_OK` with a packet
+                * length of 0. This means we must try again. This scenario
+                * arises when a clear command is performed on an lttng session.
+                */
+               BT_COMP_LOGD("Expecting a metadata packet of size 0. Retry to get a packet from the relay.");
+               goto empty_metadata_packet_retry;
        }
 
+       BT_COMP_LOGD("Writing %" PRIu64" bytes to metadata", len);
+
        data = g_new0(gchar, len);
        if (!data) {
                BT_COMP_LOGE_APPEND_CAUSE_ERRNO(self_comp,
@@ -1351,6 +1355,7 @@ enum lttng_live_get_one_metadata_status lttng_live_get_one_metadata_packet(
                goto end;
        }
 
+empty_metadata_packet_retry:
        *reply_len = len;
        status = LTTNG_LIVE_GET_ONE_METADATA_STATUS_OK;
 
This page took 0.025982 seconds and 4 git commands to generate.