From 1b58b7f58ff45470cc5e7967d8e577ad14b95ce3 Mon Sep 17 00:00:00 2001 From: Julien Desfossez Date: Mon, 18 Sep 2017 11:58:33 -0400 Subject: [PATCH] config for pending timer + rate limiting Signed-off-by: Julien Desfossez --- configure.ac | 1 + src/bin/lttng-sessiond/cmd.c | 1 + src/bin/lttng-sessiond/rotation-thread.c | 9 +++++++-- src/bin/lttng-sessiond/session.h | 1 + src/bin/lttng-sessiond/sessiond-timer.c | 13 +++++++++++++ src/common/defaults.h | 6 ++++++ 6 files changed, 29 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 016c56ece..3e51c2fff 100644 --- a/configure.ac +++ b/configure.ac @@ -341,6 +341,7 @@ _AC_DEFINE_QUOTED_AND_SUBST([DEFAULT_AGENT_BIND_ADDRESS], [localhost]) _AC_DEFINE_QUOTED_AND_SUBST([DEFAULT_NETWORK_CONTROL_BIND_ADDRESS], [0.0.0.0]) _AC_DEFINE_QUOTED_AND_SUBST([DEFAULT_NETWORK_DATA_BIND_ADDRESS], [0.0.0.0]) _AC_DEFINE_QUOTED_AND_SUBST([DEFAULT_NETWORK_VIEWER_BIND_ADDRESS], [localhost]) +_AC_DEFINE_AND_SUBST([DEFAULT_ROTATE_PENDING_RELAY_TIMER], [500000]) # Command short descriptions _AC_DEFINE_QUOTED_AND_SUBST([CMD_DESCR_ADD_CONTEXT], [Add context fields to a channel]) diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index a86e4db0b..38d0dac58 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -4211,6 +4211,7 @@ int cmd_rotate_session(struct ltt_session *session, session->rotate_count++; session->rotate_pending = true; + session->rotate_pending_relay_check_in_progress = false; session->rotate_status = LTTNG_ROTATE_STARTED; /* diff --git a/src/bin/lttng-sessiond/rotation-thread.c b/src/bin/lttng-sessiond/rotation-thread.c index 4431a9494..10c904b7b 100644 --- a/src/bin/lttng-sessiond/rotation-thread.c +++ b/src/bin/lttng-sessiond/rotation-thread.c @@ -335,7 +335,8 @@ int handle_channel_rotation_pipe(int fd, uint32_t revents, channel_info->session->rotate_pending = false; if (channel_info->session->rotate_pending_relay) { ret = sessiond_timer_rotate_pending_start( - channel_info->session, 100000); + channel_info->session, + DEFAULT_ROTATE_PENDING_RELAY_TIMER); if (ret) { ERR("Enabling rotate pending timer"); ret = -1; @@ -398,12 +399,16 @@ int handle_rotate_timer_pipe(int fd, uint32_t revents, if (ret == 0) { DBG("[rotation-thread] Rotation completed on the relay for " "session %" PRIu64, session_id); - session->rotate_pending_relay = 0; + session->rotate_pending_relay = false; sessiond_timer_rotate_pending_stop(session); } else if (ret == 1) { DBG("[rotation-thread] Rotation still pending on the relay for " "session %" PRIu64, session_id); } + /* + * Allow the timer thread to send other notifications if needed. + */ + session->rotate_pending_relay_check_in_progress = false; fprintf(stderr, "RET PENDING: %d\n", ret); ret = 0; diff --git a/src/bin/lttng-sessiond/session.h b/src/bin/lttng-sessiond/session.h index 5edd96268..6a42eafb0 100644 --- a/src/bin/lttng-sessiond/session.h +++ b/src/bin/lttng-sessiond/session.h @@ -137,6 +137,7 @@ struct ltt_session { uint64_t rotate_count; bool rotate_pending; bool rotate_pending_relay; + bool rotate_pending_relay_check_in_progress; enum lttng_rotate_status rotate_status; /* * Number of channels waiting for a rotate. diff --git a/src/bin/lttng-sessiond/sessiond-timer.c b/src/bin/lttng-sessiond/sessiond-timer.c index 1c6bc70ba..47e50ea67 100644 --- a/src/bin/lttng-sessiond/sessiond-timer.c +++ b/src/bin/lttng-sessiond/sessiond-timer.c @@ -244,11 +244,24 @@ void relay_rotation_pending_timer(struct timer_thread_parameters *ctx, struct ltt_session *session = si->si_value.sival_ptr; assert(session); + /* + * Avoid sending too many requests in case the relay is slower to + * respond than the timer period. + */ + if (session->rotate_pending_relay_check_in_progress || + !session->rotate_pending_relay) { + goto end; + } + + session->rotate_pending_relay_check_in_progress = true; ret = lttng_write(ctx->rotate_timer_pipe, &session->id, sizeof(session->id)); if (ret < sizeof(session->id)) { PERROR("wakeup rotate pipe"); } + +end: + return; } /* diff --git a/src/common/defaults.h b/src/common/defaults.h index 8669a8412..e9dfdba94 100644 --- a/src/common/defaults.h +++ b/src/common/defaults.h @@ -328,6 +328,12 @@ /* Default maximal size of message notification channel message payloads. */ #define DEFAULT_CLIENT_MAX_QUEUED_NOTIFICATIONS_COUNT 100 +/* + * Default timer value in usec for the rotate pending polling check on the + * relay when a rotation has completed on the consumer. + */ +#define DEFAULT_ROTATE_PENDING_RELAY_TIMER CONFIG_DEFAULT_ROTATE_PENDING_RELAY_TIMER + /* * Returns the default subbuf size. * -- 2.34.1