]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: peers: fix some track counter rules dont register entries for sync.
authorEmeric Brun <ebrun@haproxy.com>
Wed, 29 Nov 2017 15:15:07 +0000 (16:15 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 29 Nov 2017 18:16:22 +0000 (19:16 +0100)
This BUG was introduced with:
'MEDIUM: threads/stick-tables: handle multithreads on stick tables'

The API was reviewed to handle stick table entry updates
asynchronously and the caller must now call a 'stkable_touch_*'
function each time the content of an entry is modified to
register the entry to be synced.

There was missing call to stktable_touch_* resulting in
not propagated entries to remote peers (or local one during reload)

include/proto/session.h
include/proto/stream.h
src/proto_http.c

index d63d29eb2aa9997e79041b7bef8d3545f00c331a..f48c0d4f44ab0bebf3eb4946c94f53cb5a9b25b2 100644 (file)
@@ -62,6 +62,9 @@ static inline void session_store_counters(struct session *sess)
                        stktable_data_cast(ptr, conn_cur)--;
 
                        HA_RWLOCK_WRUNLOCK(STK_SESS_LOCK, &ts->lock);
+
+                       /* If data was modified, we need to touch to re-schedule sync */
+                       stktable_touch_local(stkctr->table, ts, 0);
                }
 
                stkctr_set_entry(stkctr, NULL);
index f3fb095ff0314c9ce8029391169160948378ec2a..8521957ec199408b35da04b782912149e4850dd5 100644 (file)
@@ -107,6 +107,9 @@ static inline void stream_store_counters(struct stream *s)
                        stktable_data_cast(ptr, conn_cur)--;
 
                        HA_RWLOCK_WRUNLOCK(STK_SESS_LOCK, &ts->lock);
+
+                       /* If data was modified, we need to touch to re-schedule sync */
+                       stktable_touch_local(s->stkctr[i].table, ts, 0);
                }
                stkctr_set_entry(&s->stkctr[i], NULL);
                stksess_kill_if_expired(s->stkctr[i].table, ts, 1);
@@ -142,6 +145,9 @@ static inline void stream_stop_content_counters(struct stream *s)
                        stktable_data_cast(ptr, conn_cur)--;
 
                        HA_RWLOCK_WRUNLOCK(STK_SESS_LOCK, &ts->lock);
+
+                       /* If data was modified, we need to touch to re-schedule sync */
+                       stktable_touch_local(s->stkctr[i].table, ts, 0);
                }
                stkctr_set_entry(&s->stkctr[i], NULL);
                stksess_kill_if_expired(s->stkctr[i].table, ts, 1);
@@ -174,6 +180,9 @@ static inline void stream_start_counters(struct stktable *t, struct stksess *ts)
                ts->expire = tick_add(now_ms, MS_TO_TICKS(t->expire));
 
        HA_RWLOCK_WRUNLOCK(STK_SESS_LOCK, &ts->lock);
+
+       /* If data was modified, we need to touch to re-schedule sync */
+       stktable_touch_local(t, ts, 0);
 }
 
 /* Enable tracking of stream counters as <stkctr> on stksess <ts>. The caller is
@@ -221,6 +230,9 @@ static void inline stream_inc_http_req_ctr(struct stream *s)
                                               stkctr->table->data_arg[STKTABLE_DT_HTTP_REQ_RATE].u, 1);
 
                HA_RWLOCK_WRUNLOCK(STK_SESS_LOCK, &ts->lock);
+
+               /* If data was modified, we need to touch to re-schedule sync */
+               stktable_touch_local(stkctr->table, ts, 0);
        }
 }
 
@@ -255,6 +267,9 @@ static void inline stream_inc_be_http_req_ctr(struct stream *s)
                                               stkctr->table->data_arg[STKTABLE_DT_HTTP_REQ_RATE].u, 1);
 
                HA_RWLOCK_WRUNLOCK(STK_SESS_LOCK, &ts->lock);
+
+               /* If data was modified, we need to touch to re-schedule sync */
+               stktable_touch_local(stkctr->table, ts, 0);
        }
 }
 
@@ -293,6 +308,9 @@ static void inline stream_inc_http_err_ctr(struct stream *s)
                                               stkctr->table->data_arg[STKTABLE_DT_HTTP_ERR_RATE].u, 1);
 
                HA_RWLOCK_WRUNLOCK(STK_SESS_LOCK, &ts->lock);
+
+               /* If data was modified, we need to touch to re-schedule sync */
+               stktable_touch_local(stkctr->table, ts, 0);
        }
 }
 
index 04771b78d80f04690205fbe4421994b3a017158a..7dd0daf9dd00b93e79d1f2d8543c366d8d4519ca 100644 (file)
@@ -2754,6 +2754,9 @@ resume_execution:
                                                                               t->data_arg[STKTABLE_DT_HTTP_REQ_RATE].u, 1);
 
                                                HA_RWLOCK_WRUNLOCK(STK_SESS_LOCK, &ts->lock);
+
+                                               /* If data was modified, we need to touch to re-schedule sync */
+                                               stktable_touch_local(t, ts, 0);
                                        }
 
                                        stkctr_set_flags(&s->stkctr[trk_idx(rule->action)], STKCTR_TRACK_CONTENT);
@@ -3054,6 +3057,9 @@ resume_execution:
 
                                        HA_RWLOCK_WRUNLOCK(STK_SESS_LOCK, &ts->lock);
 
+                                       /* If data was modified, we need to touch to re-schedule sync */
+                                       stktable_touch_local(t, ts, 0);
+
                                        stkctr_set_flags(&s->stkctr[trk_idx(rule->action)], STKCTR_TRACK_CONTENT);
                                        if (sess->fe != s->be)
                                                stkctr_set_flags(&s->stkctr[trk_idx(rule->action)], STKCTR_TRACK_BACKEND);