From: David Goulet Date: Thu, 28 Nov 2013 18:08:10 +0000 (-0500) Subject: Fix: don't fail on push metadata if no channel X-Git-Tag: v2.4.0-rc2~20 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=000baf6aa0ad8d7a985f147f1f47337b564150ca;p=lttng-tools.git Fix: don't fail on push metadata if no channel The comments in the code explains it well but in a nutshell, this is an acceptable race between the creation of the metadata on the consumer side and the push metadata from the session daemon for that channel. This race is resolved by either having the consumer requesting metadata or the session is stopped which will in both situation push the metadata to the consumer. Without that fix, the session daemon flags the registry's metadata to be "closed" which usually indicates that the consumer is not responding leading to the consumer thread exiting in the session daemon. Acked-by: Julien Desfossez Signed-off-by: David Goulet --- diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c index 41a321f0a..72a3223c1 100644 --- a/src/bin/lttng-sessiond/ust-app.c +++ b/src/bin/lttng-sessiond/ust-app.c @@ -481,6 +481,20 @@ push_data: ret = consumer_push_metadata(socket, registry->metadata_key, metadata_str, len, offset); if (ret < 0) { + /* + * There is an acceptable race here between the registry metadata key + * assignment and the creation on the consumer. The session daemon can + * concurrently push metadata for this registry while being created on + * the consumer since the metadata key of the registry is assigned + * *before* it is setup to avoid the consumer to ask for metadata that + * could possibly be not found in the session daemon. + * + * The metadata will get pushed either by the session being stopped or + * the consumer requesting metadata if that race is triggered. + */ + if (ret == -LTTCOMM_CONSUMERD_CHANNEL_FAIL) { + ret = 0; + } ret_val = ret; goto error_push; } diff --git a/src/common/ust-consumer/ust-consumer.c b/src/common/ust-consumer/ust-consumer.c index 83aa5986f..a077faafb 100644 --- a/src/common/ust-consumer/ust-consumer.c +++ b/src/common/ust-consumer/ust-consumer.c @@ -1451,8 +1451,15 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, channel = consumer_find_channel(key); if (!channel) { - ERR("UST consumer push metadata %" PRIu64 " not found", key); - ret_code = LTTNG_ERR_UST_CHAN_NOT_FOUND; + /* + * This is possible if the metadata creation on the consumer side + * is in flight vis-a-vis a concurrent push metadata from the + * session daemon. Simply return that the channel failed and the + * session daemon will handle that message correctly considering + * that this race is acceptable thus the DBG() statement here. + */ + DBG("UST consumer push metadata %" PRIu64 " not found", key); + ret_code = LTTCOMM_CONSUMERD_CHANNEL_FAIL; goto end_msg_sessiond; }