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

@ -2984,7 +2984,7 @@ void config_set_global_defaults()
gateway.peer_password[0] = '\0';
gateway.log_target = MXB_LOG_TARGET_DEFAULT;
gateway.qc_cache_properties.max_size = get_total_memory() * 0.4;
gateway.qc_cache_properties.max_size = get_total_memory() * 0.15;
if (gateway.qc_cache_properties.max_size == 0)
{

View File

@ -513,6 +513,7 @@ int dcb_read(DCB* dcb,
GWBUF** head,
int maxbytes)
{
mxb_assert(dcb->owner == RoutingWorker::get_current());
int nsingleread = 0;
int nreadtotal = 0;
@ -853,6 +854,7 @@ static int dcb_log_errors_SSL(DCB* dcb, int ret)
*/
int dcb_write(DCB* dcb, GWBUF* queue)
{
mxb_assert(dcb->owner == RoutingWorker::get_current());
dcb->writeqlen += gwbuf_length(queue);
// The following guarantees that queue is not NULL
if (!dcb_write_parameter_check(dcb, queue))
@ -2825,6 +2827,7 @@ public:
RoutingWorker& rworker = static_cast<RoutingWorker&>(worker);
if (dcb_is_still_valid(m_dcb, rworker.id()) && m_dcb->m_uid == m_uid)
{
mxb_assert(m_dcb->owner == RoutingWorker::get_current());
m_dcb->fakeq = m_buffer;
dcb_handler(m_dcb, m_ev);
}
@ -2845,6 +2848,7 @@ static void poll_add_event_to_dcb(DCB* dcb, GWBUF* buf, uint32_t ev)
{
if (dcb == this_thread.current_dcb)
{
mxb_assert(dcb->owner == RoutingWorker::get_current());
// If the fake event is added to the current DCB, we arrange for
// it to be handled immediately in dcb_handler() when the handling
// of the current events are done...

View File

@ -177,10 +177,15 @@ public:
mxb_assert(peek(canonical_stmt) == nullptr);
mxb_assert(this_unit.classifier);
// 0xffffff is the maximum packet size, 4 is for packet header and 1 is for command byte. These are
// MariaDB/MySQL protocol specific values that are also defined in <maxscale/protocol/mysql.h> but
// should not be exposed to the core.
constexpr int64_t max_entry_size = 0xffffff - 5;
int64_t cache_max_size = this_unit.cache_max_size() / config_get_global_options()->n_threads;
int64_t size = canonical_stmt.size();
if (size <= cache_max_size)
if (size < max_entry_size && size <= cache_max_size)
{
int64_t required_space = (m_stats.size + size) - cache_max_size;

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,