Commit 5e7173b8 authored by Geoff Simmons's avatar Geoff Simmons

trackrdrd: truncate data if it includes nulls (due to exceeding shm_reclen)

           add the statistic data_truncated for this case
           remove the memory barriers
parent 418c3610
...@@ -55,7 +55,6 @@ ...@@ -55,7 +55,6 @@
#include <dlfcn.h> #include <dlfcn.h>
#include "vsb.h" #include "vsb.h"
#include "vmb.h"
#include "vpf.h" #include "vpf.h"
#include "libvarnish.h" #include "libvarnish.h"
...@@ -228,6 +227,7 @@ data_submit(dataentry *de) ...@@ -228,6 +227,7 @@ data_submit(dataentry *de)
{ {
CHECK_OBJ_NOTNULL(de, DATA_MAGIC); CHECK_OBJ_NOTNULL(de, DATA_MAGIC);
assert(de->state == DATA_DONE); assert(de->state == DATA_DONE);
AZ(memchr(de->data, '\0', de->end));
LOG_Log(LOG_DEBUG, "submit: data=[%.*s]", de->end, de->data); LOG_Log(LOG_DEBUG, "submit: data=[%.*s]", de->end, de->data);
if (de->hasdata == false) { if (de->hasdata == false) {
de->state = DATA_EMPTY; de->state = DATA_EMPTY;
...@@ -624,6 +624,8 @@ static inline void ...@@ -624,6 +624,8 @@ static inline void
append(dataentry *entry, enum VSL_tag_e tag, unsigned xid, char *data, append(dataentry *entry, enum VSL_tag_e tag, unsigned xid, char *data,
int datalen) int datalen)
{ {
char *null;
CHECK_OBJ_NOTNULL(entry, DATA_MAGIC); CHECK_OBJ_NOTNULL(entry, DATA_MAGIC);
/* Data overflow */ /* Data overflow */
if (entry->end + datalen + 1 > config.maxdata) { if (entry->end + datalen + 1 > config.maxdata) {
...@@ -634,11 +636,18 @@ append(dataentry *entry, enum VSL_tag_e tag, unsigned xid, char *data, ...@@ -634,11 +636,18 @@ append(dataentry *entry, enum VSL_tag_e tag, unsigned xid, char *data,
dtbl.w_stats.data_overflows++; dtbl.w_stats.data_overflows++;
return; return;
} }
/* Null chars in the payload means that the data was truncated in the
log, due to exceeding shm_reclen. */
if ((null = memchr(data, '\0', datalen)) != NULL) {
datalen = null - data;
LOG_Log(LOG_ALERT, "%s: Data truncated in SHM log, XID=%d, data=[%.*s]",
VSL_tags[tag], xid, datalen, data);
dtbl.w_stats.data_truncated++;
}
entry->data[entry->end] = '&'; entry->data[entry->end] = '&';
entry->end++; entry->end++;
memcpy(&entry->data[entry->end], data, datalen); memcpy(&entry->data[entry->end], data, datalen);
VWMB();
entry->end += datalen; entry->end += datalen;
if (entry->end > dtbl.w_stats.data_hi) if (entry->end > dtbl.w_stats.data_hi)
dtbl.w_stats.data_hi = entry->end; dtbl.w_stats.data_hi = entry->end;
......
...@@ -58,6 +58,7 @@ log_output(void) ...@@ -58,6 +58,7 @@ log_output(void)
"data_hi=%u " "data_hi=%u "
"key_hi=%u " "key_hi=%u "
"data_overflows=%u " "data_overflows=%u "
"data_truncated=%u "
"key_overflows=%u " "key_overflows=%u "
"done=%u " "done=%u "
"open=%u " "open=%u "
...@@ -76,6 +77,7 @@ log_output(void) ...@@ -76,6 +77,7 @@ log_output(void)
dtbl.w_stats.data_hi, dtbl.w_stats.data_hi,
dtbl.w_stats.key_hi, dtbl.w_stats.key_hi,
dtbl.w_stats.data_overflows, dtbl.w_stats.data_overflows,
dtbl.w_stats.data_truncated,
dtbl.w_stats.key_overflows, dtbl.w_stats.key_overflows,
dtbl.r_stats.done, dtbl.r_stats.done,
dtbl.r_stats.open, dtbl.r_stats.open,
......
...@@ -151,6 +151,7 @@ struct data_writer_stats_s { ...@@ -151,6 +151,7 @@ struct data_writer_stats_s {
unsigned data_hi; /* max string length of entry->data */ unsigned data_hi; /* max string length of entry->data */
unsigned key_hi; /* max string length of entry->key */ unsigned key_hi; /* max string length of entry->key */
unsigned data_overflows; /* config.maxdata exceeded */ unsigned data_overflows; /* config.maxdata exceeded */
unsigned data_truncated; /* shm_reclen exceeded */
unsigned key_overflows; /* config.maxkeylen exceeded */ unsigned key_overflows; /* config.maxkeylen exceeded */
unsigned abandoned; /* Worker threads abandoned */ unsigned abandoned; /* Worker threads abandoned */
}; };
......
...@@ -38,7 +38,6 @@ ...@@ -38,7 +38,6 @@
#include "trackrdrd.h" #include "trackrdrd.h"
#include "vas.h" #include "vas.h"
#include "miniobj.h" #include "miniobj.h"
#include "vmb.h"
#define VERSION_LEN 64 #define VERSION_LEN 64
#define CLIENT_ID_LEN 80 #define CLIENT_ID_LEN 80
...@@ -130,7 +129,7 @@ wrk_send(void **mq_worker, dataentry *entry, worker_data_t *wrk) ...@@ -130,7 +129,7 @@ wrk_send(void **mq_worker, dataentry *entry, worker_data_t *wrk)
AN(mq_worker); AN(mq_worker);
/* XXX: report entry->incomplete to backend ? */ /* XXX: report entry->incomplete to backend ? */
VRMB(); AZ(memchr(entry->data, '\0', entry->end));
errnum = mqf.send(*mq_worker, entry->data, entry->end, errnum = mqf.send(*mq_worker, entry->data, entry->end,
entry->key, entry->keylen, &err); entry->key, entry->keylen, &err);
if (errnum != 0) { if (errnum != 0) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment