Merge branch '2.2' into develop

This commit is contained in:
Niclas Antti
2018-06-01 09:33:04 +03:00
9 changed files with 86 additions and 59 deletions

View File

@ -5,7 +5,7 @@
set(MAXSCALE_VERSION_MAJOR "2" CACHE STRING "Major version") set(MAXSCALE_VERSION_MAJOR "2" CACHE STRING "Major version")
set(MAXSCALE_VERSION_MINOR "2" CACHE STRING "Minor version") set(MAXSCALE_VERSION_MINOR "2" CACHE STRING "Minor version")
set(MAXSCALE_VERSION_PATCH "7" CACHE STRING "Patch version") set(MAXSCALE_VERSION_PATCH "8" CACHE STRING "Patch version")
# This should only be incremented if a package is rebuilt # This should only be incremented if a package is rebuilt
set(MAXSCALE_BUILD_NUMBER 1 CACHE STRING "Release number") set(MAXSCALE_BUILD_NUMBER 1 CACHE STRING "Release number")

View File

@ -381,15 +381,6 @@ extern char *gwbuf_get_property(GWBUF *buf, const char *name);
*/ */
extern GWBUF *gwbuf_make_contiguous(GWBUF *buf); extern GWBUF *gwbuf_make_contiguous(GWBUF *buf);
/**
* Add hint to a buffer.
*
* @param buf The buffer to add the hint to
* @param hint The hint. Note that the ownership of @c hint is transferred
* to @c buf.
*/
extern void gwbuf_add_hint(GWBUF *buf, HINT *hint);
/** /**
* Add a buffer object to GWBUF buffer. * Add a buffer object to GWBUF buffer.
* *

View File

@ -53,6 +53,7 @@ typedef struct hint
HINT *hint_alloc(HINT_TYPE, void *, unsigned int); HINT *hint_alloc(HINT_TYPE, void *, unsigned int);
HINT *hint_create_parameter(HINT *, char *, const char *); HINT *hint_create_parameter(HINT *, char *, const char *);
HINT *hint_create_route(HINT *, HINT_TYPE, const char *); HINT *hint_create_route(HINT *, HINT_TYPE, const char *);
HINT *hint_splice(HINT *head, HINT *list);
void hint_free(HINT *); void hint_free(HINT *);
HINT *hint_dup(const HINT *); HINT *hint_dup(const HINT *);
bool hint_exists(HINT **, HINT_TYPE); bool hint_exists(HINT **, HINT_TYPE);

View File

@ -69,6 +69,7 @@ TestConnections::TestConnections(int argc, char *argv[]):
global_result(0), global_result(0),
use_snapshots(false), use_snapshots(false),
no_backend_log_copy(false), no_backend_log_copy(false),
no_maxscale_log_copy(false),
verbose(false), verbose(false),
smoke(true), smoke(true),
binlog_cmd_option(0), binlog_cmd_option(0),
@ -104,15 +105,17 @@ TestConnections::TestConnections(int argc, char *argv[]):
static struct option long_options[] = static struct option long_options[] =
{ {
{"verbose", no_argument, 0, 'v'}, {"help", no_argument, 0, 'h'},
{"silent", no_argument, 0, 'n'}, {"verbose", no_argument, 0, 'v'},
{"help", no_argument, 0, 'h'}, {"silent", no_argument, 0, 'n'},
{"quiet", no_argument, 0, 'q'},
{"no-maxscale-start", no_argument, 0, 's'}, {"no-maxscale-start", no_argument, 0, 's'},
{"no-nodes-check", no_argument, 0, 'r'}, {"no-maxscale-init", no_argument, 0, 'i'},
{"quiet", no_argument, 0, 'q'}, {"no-nodes-check", no_argument, 0, 'r'},
{"restart-galera", no_argument, 0, 'g'}, {"restart-galera", no_argument, 0, 'g'},
{"no-timeouts", no_argument, 0, 'z'}, {"no-timeouts", no_argument, 0, 'z'},
{"no-galera", no_argument, 0, 'y'}, {"no-galera", no_argument, 0, 'y'},
{"local-maxscale", no_argument, 0, 'l'},
{0, 0, 0, 0} {0, 0, 0, 0}
}; };
@ -120,7 +123,7 @@ TestConnections::TestConnections(int argc, char *argv[]):
int option_index = 0; int option_index = 0;
bool restart_galera = false; bool restart_galera = false;
while ((c = getopt_long(argc, argv, "vnqhsirgzy", long_options, &option_index)) != -1) while ((c = getopt_long(argc, argv, "hvnqsirgzyl", long_options, &option_index)) != -1)
{ {
switch (c) switch (c)
{ {
@ -137,22 +140,25 @@ TestConnections::TestConnections(int argc, char *argv[]):
break; break;
case 'h': case 'h':
printf("Options:\n" {
"-h, --help\n" printf("Options:\n");
"-v, --verbose\n"
"-q, --silent\n" struct option *o = long_options;
"-s, --no-maxscale-start\n"
"-i, --no-maxscale-init\n" while (o->name)
"-g, --restart-galera\n" {
"-y, --no-galera\n" printf("-%c, --%s\n", o->val, o->name);
"-z, --no-timeouts\n"); ++o;
exit(0); }
exit(0);
}
break; break;
case 's': case 's':
printf("Maxscale won't be started\n"); printf("Maxscale won't be started\n");
maxscale::start = false; maxscale::start = false;
break; break;
case 'i': case 'i':
printf("Maxscale won't be started and Maxscale.cnf won't be uploaded\n"); printf("Maxscale won't be started and Maxscale.cnf won't be uploaded\n");
maxscale_init = false; maxscale_init = false;
@ -177,6 +183,15 @@ TestConnections::TestConnections(int argc, char *argv[]):
no_galera = true; no_galera = true;
break; break;
case 'l':
printf("MaxScale assumed to be running locally; not started and logs not downloaded.\n");
maxscale_init = false;
no_maxscale_log_copy = true;
setenv("maxscale_IP", "127.0.0.1", true);
setenv("maxscale_network", "127.0.0.1", true);
setenv("maxscale_private_ip", "127.0.0.1", true);
break;
default: default:
printf("UNKNOWN OPTION: %c\n", c); printf("UNKNOWN OPTION: %c\n", c);
break; break;
@ -423,6 +438,11 @@ void TestConnections::read_env()
{ {
no_backend_log_copy = true; no_backend_log_copy = true;
} }
env = getenv("no_maxscale_log_copy");
if ((env != NULL) && ((strcasecmp(env, "yes") == 0) || (strcasecmp(env, "true") == 0) ))
{
no_maxscale_log_copy = true;
}
env = getenv("use_ipv6"); env = getenv("use_ipv6");
if ((env != NULL) && ((strcasecmp(env, "yes") == 0) || (strcasecmp(env, "true") == 0) )) if ((env != NULL) && ((strcasecmp(env, "yes") == 0) || (strcasecmp(env, "true") == 0) ))
{ {
@ -732,7 +752,14 @@ int TestConnections::copy_all_logs()
copy_mariadb_logs(galera, (char *) "galera"); copy_mariadb_logs(galera, (char *) "galera");
} }
return (copy_maxscale_logs(0)); int rv = 0;
if (!no_maxscale_log_copy)
{
rv = copy_maxscale_logs(0);
}
return rv;
} }
int TestConnections::copy_maxscale_logs(double timestamp) int TestConnections::copy_maxscale_logs(double timestamp)
{ {

View File

@ -131,10 +131,15 @@ public:
int copy_mariadb_logs(Mariadb_nodes *repl, char * prefix); int copy_mariadb_logs(Mariadb_nodes *repl, char * prefix);
/** /**
* @brief no_backend_log_copy if true logs from backends are not copied (needed if case of Aurora RDS backend or similar) * @brief no_backend_log_copy if true logs from backends are not copied
* (needed if case of Aurora RDS backend or similar)
*/ */
bool no_backend_log_copy; bool no_backend_log_copy;
/**
* @brief Do not download MaxScale logs.
*/
bool no_maxscale_log_copy;
/** /**
* @brief verbose if true more printing activated * @brief verbose if true more printing activated
*/ */

View File

@ -813,28 +813,6 @@ gwbuf_make_contiguous(GWBUF *orig)
return newbuf; return newbuf;
} }
void
gwbuf_add_hint(GWBUF *buf, HINT *hint)
{
HINT *ptr;
spinlock_acquire(&buf->gwbuf_lock);
if (buf->hint)
{
ptr = buf->hint;
while (ptr->next)
{
ptr = ptr->next;
}
ptr->next = hint;
}
else
{
buf->hint = hint;
}
spinlock_release(&buf->gwbuf_lock);
}
size_t gwbuf_copy_data(const GWBUF *buffer, size_t offset, size_t bytes, uint8_t* dest) size_t gwbuf_copy_data(const GWBUF *buffer, size_t offset, size_t bytes, uint8_t* dest)
{ {
uint32_t buflen; uint32_t buflen;

View File

@ -113,6 +113,32 @@ hint_create_route(HINT *head, HINT_TYPE type, const char *data)
return hint; return hint;
} }
/**
* Insert a hint list before head.
*
* @param head Element before which contents is inserted.
* May be NULL, in which case the result is list.
* @param list Hint list to prepend
* @return Head of list
*/
HINT *
hint_splice(HINT *head, HINT *list)
{
ss_dassert(list);
if (head)
{
HINT* tail = list;
while (tail->next)
{
tail = tail->next;
}
tail->next = head;
}
return list;
}
/** /**
* Create name/value parameter hint * Create name/value parameter hint
* *

View File

@ -467,10 +467,6 @@ test1()
ss_info_dassert(size == buflen, "Incorrect buffer size"); ss_info_dassert(size == buflen, "Incorrect buffer size");
ss_info_dassert(0 == GWBUF_EMPTY(buffer), "Buffer should not be empty"); ss_info_dassert(0 == GWBUF_EMPTY(buffer), "Buffer should not be empty");
ss_info_dassert(GWBUF_IS_TYPE_UNDEFINED(buffer), "Buffer type should be undefined"); ss_info_dassert(GWBUF_IS_TYPE_UNDEFINED(buffer), "Buffer type should be undefined");
ss_dfprintf(stderr, "\t..done\nSet a hint for the buffer");
hint = hint_create_parameter(NULL, (char*)"name", (char*)"value");
gwbuf_add_hint(buffer, hint);
ss_info_dassert(hint == buffer->hint, "Buffer should point to first and only hint");
ss_dfprintf(stderr, "\t..done\nSet a property for the buffer"); ss_dfprintf(stderr, "\t..done\nSet a property for the buffer");
gwbuf_add_property(buffer, (char*)"name", (char*)"value"); gwbuf_add_property(buffer, (char*)"name", (char*)"value");
ss_info_dassert(0 == strcmp("value", gwbuf_get_property(buffer, (char*)"name")), ss_info_dassert(0 == strcmp("value", gwbuf_get_property(buffer, (char*)"name")),

View File

@ -213,8 +213,11 @@ routeQuery(MXS_FILTER *instance, MXS_FILTER_SESSION *session, GWBUF *queue)
{ {
my_session->request = NULL; my_session->request = NULL;
my_session->query_len = 0; my_session->query_len = 0;
HINT *hint = hint_parser(my_session, queue); HINT *new_hint = hint_parser(my_session, queue);
queue->hint = hint; if (new_hint)
{
queue->hint = hint_splice(queue->hint, new_hint);
}
} }
/* Now process the request */ /* Now process the request */