Merge branch '2.3' into develop

This commit is contained in:
Markus Mäkelä
2019-04-23 12:05:18 +03:00
26 changed files with 134 additions and 78 deletions

View File

@ -58,17 +58,22 @@ static std::string do_query(MonitorServer* srv, const char* query)
// Returns a numeric version similar to mysql_get_server_version
int get_cs_version(MonitorServer* srv)
{
// GCC 4.8 appears to have a broken std::regex_constants::ECMAScript that doesn't support brackets
std::regex re("Columnstore \\([0-9]*\\)[.]\\([0-9]*\\)[.]\\([0-9]*\\)-[0-9]*",
std::regex_constants::basic);
std::string result = do_query(srv, "SELECT @@version_comment");
std::smatch match;
int rval = 0;
std::string prefix = "Columnstore ";
std::string result = do_query(srv, "SELECT @@version_comment");
auto pos = result.find(prefix);
if (std::regex_match(result, match, re) && match.size() == 4)
if (pos != std::string::npos)
{
rval = atoi(match[1].str().c_str()) * 10000 + atoi(match[2].str().c_str()) * 100
+ atoi(match[3].str().c_str());
std::istringstream os(result.substr(pos + prefix.length()));
int major = 0, minor = 0, patch = 0;
char dot;
os >> major;
os >> dot;
os >> minor;
os >> dot;
os >> patch;
rval = major * 10000 + minor * 100 + patch;
}
return rval;

View File

@ -32,6 +32,8 @@ LocalClient::LocalClient(MYSQL_session* session, MySQLProtocol* proto, int fd)
, m_self_destruct(false)
{
MXB_POLL_DATA::handler = LocalClient::poll_handler;
m_protocol.owner_dcb = nullptr;
m_protocol.stored_query = nullptr;
}
LocalClient::~LocalClient()

View File

@ -304,6 +304,17 @@ void RWBackend::process_packets(GWBUF* result)
auto end = std::next(it, len);
uint8_t cmd = *it;
// Ignore the tail end of a large packet large packet. Only resultsets can generate packets this large
// and we don't care what the contents are and thus it is safe to ignore it.
bool skip_next = m_skip_next;
m_skip_next = len == GW_MYSQL_MAX_PACKET_LEN;
if (skip_next)
{
it = end;
continue;
}
switch (m_reply_state)
{
case REPLY_STATE_START:

View File

@ -33,6 +33,7 @@
#include <maxscale/alloc.h>
#include <maxscale/buffer.hh>
#include <maxscale/utils.hh>
#include <maxscale/routingworker.hh>
std::pair<std::string, std::string> get_avrofile_and_gtid(std::string file);
@ -238,22 +239,14 @@ bool file_in_dir(const char* dir, const char* file)
}
/**
* @brief The client callback for sending data
*
* @param dcb Client DCB
* @param reason Why the callback was called
* @param userdata Data provided when the callback was added
* @return Always 0
* Queue the client callback for execution
*/
int avro_client_callback(DCB* dcb, DCB_REASON reason, void* userdata)
void AvroSession::queue_client_callback()
{
if (reason == DCB_REASON_DRAINED)
{
AvroSession* client = static_cast<AvroSession*>(userdata);
client->client_callback();
}
return 0;
auto worker = mxs::RoutingWorker::get(mxs::RoutingWorker::MAIN);
worker->execute([this]() {
client_callback();
}, mxs::RoutingWorker::EXECUTE_QUEUED);
}
/**
@ -337,11 +330,7 @@ void AvroSession::process_command(GWBUF* queue)
if (file_in_dir(router->avrodir.c_str(), avro_binfile.c_str()))
{
/* set callback routine for data sending */
dcb_add_callback(dcb, DCB_REASON_DRAINED, avro_client_callback, this);
/* Add fake event that will call the avro_client_callback() routine */
poll_fake_write_event(dcb);
queue_client_callback();
}
else
{
@ -733,7 +722,7 @@ void AvroSession::client_callback()
if (next_file || read_more)
{
poll_fake_write_event(dcb);
queue_client_callback();
}
}

View File

@ -173,11 +173,6 @@ public:
*/
int routeQuery(GWBUF* buffer);
/**
* Handler for the EPOLLOUT event
*/
void client_callback();
private:
AvroSession(Avro* instance, MXS_SESSION* session);
@ -190,6 +185,8 @@ private:
bool seek_to_gtid();
bool stream_data();
void rotate_avro_file(std::string fullname);
void client_callback();
void queue_client_callback();
};
void read_table_info(uint8_t* ptr,