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;
}
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;
}