config for pending timer + rate limiting
authorJulien Desfossez <jdesfossez@efficios.com>
Mon, 18 Sep 2017 15:58:33 +0000 (11:58 -0400)
committerJulien Desfossez <jdesfossez@efficios.com>
Mon, 18 Sep 2017 15:58:33 +0000 (11:58 -0400)
Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
configure.ac
src/bin/lttng-sessiond/cmd.c
src/bin/lttng-sessiond/rotation-thread.c
src/bin/lttng-sessiond/session.h
src/bin/lttng-sessiond/sessiond-timer.c
src/common/defaults.h

index 016c56ece4d97ab5b07a2eb920132922ae82666b..3e51c2fff87c51f21a34214898e5ebdc95879aa9 100644 (file)
@@ -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])
index a86e4db0b34a8621a3a2fec70a690d1b7a82a493..38d0dac58f0935c65651621cf80c7cb72f9d146b 100644 (file)
@@ -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;
 
        /*
index 4431a9494988a0c69f8279e5d19721f74696ba74..10c904b7b66cd865c9dd91f0f9a6868b7c2c7fb3 100644 (file)
@@ -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;
index 5edd962688df79ce3188d48a8a6ee4b8444e02e6..6a42eafb013bb128607774b2f5040a8e10348e72 100644 (file)
@@ -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.
index 1c6bc70baadb052ea552c292ae3255b63e08b7c8..47e50ea675e8d46d1177d5b4b0f16ef0467575aa 100644 (file)
@@ -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;
 }
 
 /*
index 8669a84129e604276e7f6f8f8b6be9878cdaf0d8..e9dfdba94b7d583338449e73d2a08fd1aff63cec 100644 (file)
 /* 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.
  *
This page took 0.030532 seconds and 5 git commands to generate.