Merge branch '2.1' into develop

This commit is contained in:
Markus Mäkelä
2017-06-05 13:25:27 +03:00
39 changed files with 300 additions and 257 deletions

View File

@ -426,6 +426,12 @@ createInstance(SERVICE *service, char **options)
inst->block_size = config_get_integer(params, "block_size");
MXS_CONFIG_PARAMETER *param = config_get_param(params, "source");
inst->gtid.domain = 0;
inst->gtid.event_num = 0;
inst->gtid.seq = 0;
inst->gtid.server_id = 0;
inst->gtid.timestamp = 0;
memset(&inst->active_maps, 0, sizeof(inst->active_maps));
bool err = false;
if (param)
@ -719,11 +725,9 @@ static void freeSession(MXS_ROUTER* router_instance, MXS_ROUTER_SESSION* router_
{
AVRO_INSTANCE *router = (AVRO_INSTANCE *) router_instance;
AVRO_CLIENT *client = (AVRO_CLIENT *) router_client_ses;
int prev_val;
prev_val = atomic_add(&router->stats.n_clients, -1);
ss_debug(int prev_val = )atomic_add(&router->stats.n_clients, -1);
ss_dassert(prev_val > 0);
(void) prev_val;
free(client->uuid);
maxavro_file_close(client->file_handle);
@ -778,9 +782,6 @@ static void closeSession(MXS_ROUTER *instance, MXS_ROUTER_SESSION *router_sessio
spinlock_release(&client->file_lock);
spinlock_release(&client->catch_lock);
/* decrease server registered slaves counter */
atomic_add(&router->stats.n_clients, -1);
}
/**

View File

@ -114,6 +114,7 @@ AVRO_TABLE* avro_table_alloc(const char* filepath, const char* json_schema, cons
&table->avro_schema))
{
MXS_ERROR("Avro error: %s", avro_strerror());
MXS_INFO("Avro schema: %s", json_schema);
MXS_FREE(table);
return NULL;
}

View File

@ -140,6 +140,7 @@ void avro_index_file(AVRO_INSTANCE *router, const char* filename)
errmsg = NULL;
prev_gtid = gtid;
}
json_decref(row);
}
else
{
@ -205,7 +206,7 @@ void avro_update_index(AVRO_INSTANCE* router)
/** The SQL for the in-memory used_tables table */
static const char *insert_sql = "INSERT OR IGNORE INTO "MEMORY_TABLE_NAME
"(domain, server_id, sequence, binlog_timestamp, table_name)"
" VALUES (%lu, %lu, %lu, %lu, \"%s\")";
" VALUES (%lu, %lu, %lu, %u, \"%s\")";
/**
* @brief Add a used table to the current transaction

View File

@ -102,16 +102,16 @@ char* json_new_schema_from_table(TABLE_MAP *map)
json_object_set_new(schema, "name", json_string("ChangeRecord"));
json_t *array = json_array();
json_array_append(array, json_pack_ex(&err, 0, "{s:s, s:s}", "name",
avro_domain, "type", "int"));
json_array_append(array, json_pack_ex(&err, 0, "{s:s, s:s}", "name",
avro_server_id, "type", "int"));
json_array_append(array, json_pack_ex(&err, 0, "{s:s, s:s}", "name",
avro_sequence, "type", "int"));
json_array_append(array, json_pack_ex(&err, 0, "{s:s, s:s}", "name",
avro_event_number, "type", "int"));
json_array_append(array, json_pack_ex(&err, 0, "{s:s, s:s}", "name",
avro_timestamp, "type", "int"));
json_array_append_new(array, json_pack_ex(&err, 0, "{s:s, s:s}", "name",
avro_domain, "type", "int"));
json_array_append_new(array, json_pack_ex(&err, 0, "{s:s, s:s}", "name",
avro_server_id, "type", "int"));
json_array_append_new(array, json_pack_ex(&err, 0, "{s:s, s:s}", "name",
avro_sequence, "type", "int"));
json_array_append_new(array, json_pack_ex(&err, 0, "{s:s, s:s}", "name",
avro_event_number, "type", "int"));
json_array_append_new(array, json_pack_ex(&err, 0, "{s:s, s:s}", "name",
avro_timestamp, "type", "int"));
/** Enums and other complex types are defined with complete JSON objects
* instead of string values */
@ -119,16 +119,19 @@ char* json_new_schema_from_table(TABLE_MAP *map)
"name", "EVENT_TYPES", "symbols", "insert",
"update_before", "update_after", "delete");
json_array_append(array, json_pack_ex(&err, 0, "{s:s, s:o}", "name", avro_event_type,
"type", event_types));
// Ownership of `event_types` is stolen when using the `o` format
json_array_append_new(array, json_pack_ex(&err, 0, "{s:s, s:o}", "name", avro_event_type,
"type", event_types));
for (uint64_t i = 0; i < map->columns; i++)
{
json_array_append(array, json_pack_ex(&err, 0, "{s:s, s:s, s:s, s:i}",
"name", create->column_names[i],
"type", column_type_to_avro_type(map->column_types[i]),
"real_type", create->column_types[i],
"length", create->column_lengths[i]));
ss_info_dassert(create->column_names[i] && *create->column_names[i],
"Column name should not be empty or NULL");
json_array_append_new(array, json_pack_ex(&err, 0, "{s:s, s:s, s:s, s:i}",
"name", create->column_names[i],
"type", column_type_to_avro_type(map->column_types[i]),
"real_type", create->column_types[i],
"length", create->column_lengths[i]));
}
json_object_set_new(schema, "fields", array);
char* rval = json_dumps(schema, JSON_PRESERVE_ORDER);
@ -543,6 +546,7 @@ static const char *extract_field_name(const char* ptr, char* dest, size_t size)
dest[bytes] = '\0';
make_valid_avro_identifier(dest);
ss_dassert(strlen(dest) > 0);
}
else
{
@ -555,7 +559,7 @@ static const char *extract_field_name(const char* ptr, char* dest, size_t size)
int extract_type_length(const char* ptr, char *dest)
{
/** Skip any leading whitespace */
while (isspace(*ptr) || *ptr == '`')
while (*ptr && (isspace(*ptr) || *ptr == '`'))
{
ptr++;
}
@ -565,7 +569,7 @@ int extract_type_length(const char* ptr, char *dest)
/** Skip characters until we either hit a whitespace character or the start
* of the length definition. */
while (!isspace(*ptr) && *ptr != '(')
while (*ptr && !isspace(*ptr) && *ptr != '(')
{
ptr++;
}
@ -576,7 +580,7 @@ int extract_type_length(const char* ptr, char *dest)
dest[typelen] = '\0';
/** Skip whitespace */
while (isspace(*ptr))
while (*ptr && isspace(*ptr))
{
ptr++;
}
@ -641,6 +645,7 @@ static int process_column_definition(const char *nameptr, char*** dest, char***
lengths[i] = len;
types[i] = MXS_STRDUP_A(type);
names[i] = MXS_STRDUP_A(colname);
ss_info_dassert(*names[i] && *types[i], "`name` and `type` must not be empty");
i++;
}

View File

@ -1575,8 +1575,8 @@ struct subcommand alteroptions[] =
"\n"
"address Server address\n"
"port Server port\n"
"monuser Monitor user for this server\n"
"monpw Monitor password for this server\n"
"monitoruser Monitor user for this server\n"
"monitorpw Monitor password for this server\n"
"ssl Enable SSL, value must be 'required'\n"
"ssl_key Path to SSL private key\n"
"ssl_cert Path to SSL certificate\n"