From 9e794c1115c765ab8481c5666cfaddf5962a8974 Mon Sep 17 00:00:00 2001 From: David Goulet Date: Thu, 28 Nov 2013 13:08:10 -0500 Subject: [PATCH] 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 --- src/bin/lttng-sessiond/ust-app.c | 14 ++++++++++++++ src/common/ust-consumer/ust-consumer.c | 11 +++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c index cb3a2747b..58b8080b5 100644 --- a/src/bin/lttng-sessiond/ust-app.c +++ b/src/bin/lttng-sessiond/ust-app.c @@ -464,6 +464,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 e92e71097..e315c4681 100644 --- a/src/common/ust-consumer/ust-consumer.c +++ b/src/common/ust-consumer/ust-consumer.c @@ -1390,8 +1390,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; } -- 2.34.1