1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-30 19:23:07 +03:00

MCOL-605 limit connections for I_S table

I_S.COLUMNSTORE_FILES now caches a connection per dbroot instead of
using a connection per file.
This commit is contained in:
Andrew Hutchings
2017-03-05 09:58:20 +00:00
parent f19710126a
commit 468fc8c260

View File

@ -49,27 +49,14 @@ ST_FIELD_INFO is_columnstore_files_fields[] =
{0, 0, MYSQL_TYPE_NULL, 0, 0, 0, 0}
};
static bool get_file_sizes(int db_root, const char *fileName, off_t *fileSize, off_t *compressedFileSize)
static bool get_file_sizes(messageqcpp::MessageQueueClient *msgQueueClient, const char *fileName, off_t *fileSize, off_t *compressedFileSize)
{
oam::Oam oam_instance;
messageqcpp::MessageQueueClient *msgQueueClient;
std::ostringstream oss;
messageqcpp::ByteStream bs;
messageqcpp::ByteStream::byte rc;
std::string errMsg;
int pmId = 0;
oam_instance.getDbrootPmConfig(db_root, pmId);
oss << "pm" << pmId << "_WriteEngineServer";
try
{
msgQueueClient = new messageqcpp::MessageQueueClient(oss.str());
}
catch (...)
{
delete msgQueueClient;
return false;
}
bs << (messageqcpp::ByteStream::byte) WriteEngine::WE_SVR_GET_FILESIZE;
// header??
bs << fileName;
@ -86,12 +73,27 @@ static bool get_file_sizes(int db_root, const char *fileName, off_t *fileSize, o
*sbs >> errMsg;
*sbs >> *fileSize;
*sbs >> *compressedFileSize;
delete msgQueueClient;
return true;
}
static bool is_columnstore_files_get_entries(THD *thd, TABLE_LIST *tables, BRM::OID_t oid, std::vector<struct BRM::EMEntry> &entries)
catch (...)
{
return false;
}
}
static void cleanup(std::map<int, messageqcpp::MessageQueueClient*> &clients)
{
for(std::map<int, messageqcpp::MessageQueueClient*>::iterator itr = clients.begin(); itr != clients.end(); itr++)
{
delete itr->second;
}
}
static int is_columnstore_files_fill(THD *thd, TABLE_LIST *tables, COND *cond)
{
BRM::DBRM *emp = new BRM::DBRM();
std::vector<struct BRM::EMEntry> entries;
CHARSET_INFO *cs = system_charset_info;
TABLE *table = tables->table;
@ -103,7 +105,25 @@ static bool is_columnstore_files_get_entries(THD *thd, TABLE_LIST *tables, BRM::
off_t fileSize = 0;
off_t compressedFileSize = 0;
we_config.initConfigCache();
std::map<int, messageqcpp::MessageQueueClient*> clients;
messageqcpp::MessageQueueClient *msgQueueClient;
oam::Oam oam_instance;
int pmId = 0;
std::ostringstream oss;
if (!emp || !emp->isDBRMReady())
{
return 1;
}
execplan::ObjectIDManager oidm;
BRM::OID_t MaxOID = oidm.size();
for(BRM::OID_t oid = 3000; oid <= MaxOID; oid++)
{
emp->getExtents(oid, entries, false, false, true);
if (entries.size() == 0)
continue;
std::vector<struct BRM::EMEntry>::const_iterator iter = entries.begin();
while ( iter != entries.end() ) //organize extents into files
@ -124,8 +144,37 @@ static bool is_columnstore_files_get_entries(THD *thd, TABLE_LIST *tables, BRM::
std::string DbRootPath = config->getConfig("SystemConfig", DbRootName.str());
fileSize = compressedFileSize = 0;
snprintf(fullFileName, WriteEngine::FILE_NAME_SIZE, "%s/%s", DbRootPath.c_str(), oidDirName);
if (!get_file_sizes(iter->dbRoot, fullFileName, &fileSize, &compressedFileSize))
try
{
msgQueueClient = clients.at(iter->dbRoot);
}
catch (...)
{
msgQueueClient = NULL;
}
if (!msgQueueClient)
{
oam_instance.getDbrootPmConfig(iter->dbRoot, pmId);
oss << "pm" << pmId << "_WriteEngineServer";
try
{
msgQueueClient = new messageqcpp::MessageQueueClient(oss.str());
}
catch (...)
{
delete msgQueueClient;
cleanup(clients);
delete emp;
return 1;
}
clients[iter->dbRoot] = msgQueueClient;
}
if (!get_file_sizes(msgQueueClient, fullFileName, &fileSize, &compressedFileSize))
{
cleanup(clients);
delete emp;
return 1;
}
table->field[3]->store(fullFileName, strlen(fullFileName), cs);
@ -151,39 +200,14 @@ static bool is_columnstore_files_get_entries(THD *thd, TABLE_LIST *tables, BRM::
}
if (schema_table_store_record(thd, table))
return 1;
iter++;
}
return 0;
}
static int is_columnstore_files_fill(THD *thd, TABLE_LIST *tables, COND *cond)
{
BRM::DBRM *emp = new BRM::DBRM();
std::vector<struct BRM::EMEntry> entries;
if (!emp || !emp->isDBRMReady())
{
return 1;
}
execplan::ObjectIDManager oidm;
BRM::OID_t MaxOID = oidm.size();
for(BRM::OID_t oid = 3000; oid <= MaxOID; oid++)
{
emp->getExtents(oid, entries, false, false, true);
if (entries.size() == 0)
continue;
if (is_columnstore_files_get_entries(thd, tables, oid, entries))
{
cleanup(clients);
delete emp;
return 1;
}
iter++;
}
}
delete emp;
return 0;
}