1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-08-01 06:46:55 +03:00

Merge pull request #1010 from tntnatbry/MCOL-3680

MCOL-3680 mysqld will abort if Columnstore.xml is missing.
Conflicts:
	dbcon/mysql/ha_mcs.cpp
This commit is contained in:
Andrew Hutchings
2020-01-28 15:26:05 +00:00
committed by Patrick LeBlanc
parent b72a9784ba
commit 9e588039d5
4 changed files with 278 additions and 71 deletions

View File

@ -30,14 +30,14 @@
#define COLUMNSTORE_MATURITY MariaDB_PLUGIN_MATURITY_STABLE #define COLUMNSTORE_MATURITY MariaDB_PLUGIN_MATURITY_STABLE
#endif #endif
static handler* calpont_create_handler(handlerton* hton, static handler* mcs_create_handler(handlerton* hton,
TABLE_SHARE* table, TABLE_SHARE* table,
MEM_ROOT* mem_root); MEM_ROOT* mem_root);
static int calpont_commit(handlerton* hton, THD* thd, bool all); static int mcs_commit(handlerton* hton, THD* thd, bool all);
static int calpont_rollback(handlerton* hton, THD* thd, bool all); static int mcs_rollback(handlerton* hton, THD* thd, bool all);
static int calpont_close_connection ( handlerton* hton, THD* thd ); static int mcs_close_connection(handlerton* hton, THD* thd );
handlerton* mcs_hton; handlerton* mcs_hton;
char cs_version[25]; char cs_version[25];
char cs_commit_hash[41]; // a commit hash is 40 characters char cs_commit_hash[41]; // a commit hash is 40 characters
@ -59,11 +59,11 @@ create_columnstore_select_handler(THD* thd, SELECT_LEX* sel);
Hash used to track the number of open tables; variable for example share Hash used to track the number of open tables; variable for example share
methods methods
*/ */
static HASH calpont_open_tables; static HASH mcs_open_tables;
#ifndef _MSC_VER #ifndef _MSC_VER
/* The mutex used to init the hash; variable for example share methods */ /* The mutex used to init the hash; variable for example share methods */
pthread_mutex_t calpont_mutex; pthread_mutex_t mcs_mutex;
#endif #endif
#ifdef DEBUG_ENTER #ifdef DEBUG_ENTER
@ -79,20 +79,20 @@ pthread_mutex_t calpont_mutex;
Function we use in the creation of our hash to get key. Function we use in the creation of our hash to get key.
*/ */
static uchar* calpont_get_key(COLUMNSTORE_SHARE* share, size_t* length, static uchar* mcs_get_key(COLUMNSTORE_SHARE* share, size_t* length,
my_bool not_used __attribute__((unused))) my_bool not_used __attribute__((unused)))
{ {
*length = share->table_name_length; *length = share->table_name_length;
return (uchar*) share->table_name; return (uchar*) share->table_name;
} }
// This one is unused // This one is unused
int calpont_discover(handlerton* hton, THD* thd, TABLE_SHARE* share) int mcs_discover(handlerton* hton, THD* thd, TABLE_SHARE* share)
{ {
DBUG_ENTER("calpont_discover"); DBUG_ENTER("mcs_discover");
DBUG_PRINT("calpont_discover", ("db: '%s' name: '%s'", share->db.str, share->table_name.str)); DBUG_PRINT("mcs_discover", ("db: '%s' name: '%s'", share->db.str, share->table_name.str));
#ifdef INFINIDB_DEBUG #ifdef INFINIDB_DEBUG
fprintf(stderr, "calpont_discover()\n"); fprintf(stderr, "mcs_discover()\n");
#endif #endif
uchar* frm_data = NULL; uchar* frm_data = NULL;
@ -114,8 +114,8 @@ int calpont_discover(handlerton* hton, THD* thd, TABLE_SHARE* share)
} }
// This f() is also unused // This f() is also unused
int calpont_discover_existence(handlerton* hton, const char* db, int mcs_discover_existence(handlerton* hton, const char* db,
const char* table_name) const char* table_name)
{ {
return ha_mcs_impl_discover_existence(db, table_name); return ha_mcs_impl_discover_existence(db, table_name);
} }
@ -144,18 +144,19 @@ static int columnstore_init_func(void* p)
mcs_hton = (handlerton*)p; mcs_hton = (handlerton*)p;
#ifndef _MSC_VER #ifndef _MSC_VER
(void) pthread_mutex_init(&calpont_mutex, MY_MUTEX_INIT_FAST); (void) pthread_mutex_init(&mcs_mutex, MY_MUTEX_INIT_FAST);
#endif #endif
(void) my_hash_init(&calpont_open_tables, system_charset_info, 32, 0, 0, (void) my_hash_init(&mcs_open_tables, system_charset_info, 32, 0, 0,
(my_hash_get_key) calpont_get_key, 0, 0); (my_hash_get_key) mcs_get_key, 0, 0);
mcs_hton->create = calpont_create_handler; mcs_hton->state = SHOW_OPTION_YES;
mcs_hton->create = mcs_create_handler;
mcs_hton->flags = HTON_CAN_RECREATE; mcs_hton->flags = HTON_CAN_RECREATE;
// mcs_hton->discover_table= calpont_discover; // mcs_hton->discover_table = mcs_discover;
// mcs_hton->discover_table_existence= calpont_discover_existence; // mcs_hton->discover_table_existence = mcs_discover_existence;
mcs_hton->commit = calpont_commit; mcs_hton->commit = mcs_commit;
mcs_hton->rollback = calpont_rollback; mcs_hton->rollback = mcs_rollback;
mcs_hton->close_connection = calpont_close_connection; mcs_hton->close_connection = mcs_close_connection;
mcs_hton->create_group_by = create_columnstore_group_by_handler; mcs_hton->create_group_by = create_columnstore_group_by_handler;
mcs_hton->create_derived = create_columnstore_derived_handler; mcs_hton->create_derived = create_columnstore_derived_handler;
mcs_hton->create_select = create_columnstore_select_handler; mcs_hton->create_select = create_columnstore_select_handler;
@ -165,37 +166,64 @@ static int columnstore_init_func(void* p)
static int columnstore_done_func(void* p) static int columnstore_done_func(void* p)
{ {
DBUG_ENTER("calpont_done_func"); DBUG_ENTER("columnstore_done_func");
my_hash_free(&calpont_open_tables); my_hash_free(&mcs_open_tables);
#ifndef _MSC_VER #ifndef _MSC_VER
pthread_mutex_destroy(&calpont_mutex); pthread_mutex_destroy(&mcs_mutex);
#endif #endif
DBUG_RETURN(0); DBUG_RETURN(0);
} }
static handler* calpont_create_handler(handlerton* hton, static handler* mcs_create_handler(handlerton* hton,
TABLE_SHARE* table, TABLE_SHARE* table,
MEM_ROOT* mem_root) MEM_ROOT* mem_root)
{ {
return new (mem_root) ha_mcs(hton, table); return new (mem_root) ha_mcs(hton, table);
} }
static int calpont_commit(handlerton* hton, THD* thd, bool all) static int mcs_commit(handlerton* hton, THD* thd, bool all)
{ {
int rc = ha_mcs_impl_commit( hton, thd, all); int rc;
try
{
rc = ha_mcs_impl_commit(hton, thd, all);
}
catch (std::runtime_error& e)
{
current_thd->raise_error_printf(ER_INTERNAL_ERROR, e.what());
rc = ER_INTERNAL_ERROR;
}
return rc; return rc;
} }
static int calpont_rollback(handlerton* hton, THD* thd, bool all) static int mcs_rollback(handlerton* hton, THD* thd, bool all)
{ {
int rc = ha_mcs_impl_rollback( hton, thd, all); int rc;
try
{
rc = ha_mcs_impl_rollback(hton, thd, all);
}
catch (std::runtime_error& e)
{
current_thd->raise_error_printf(ER_INTERNAL_ERROR, e.what());
rc = ER_INTERNAL_ERROR;
}
return rc; return rc;
} }
static int calpont_close_connection ( handlerton* hton, THD* thd ) static int mcs_close_connection(handlerton* hton, THD* thd)
{ {
int rc = ha_mcs_impl_close_connection( hton, thd); int rc;
try
{
rc = ha_mcs_impl_close_connection(hton, thd);
}
catch (std::runtime_error& e)
{
current_thd->raise_error_printf(ER_INTERNAL_ERROR, e.what());
rc = ER_INTERNAL_ERROR;
}
return rc; return rc;
} }
@ -256,7 +284,16 @@ int ha_mcs::open(const char* name, int mode, uint32_t test_if_locked)
{ {
DBUG_ENTER("ha_mcs::open"); DBUG_ENTER("ha_mcs::open");
int rc = ha_mcs_impl_open(name, mode, test_if_locked); int rc;
try
{
rc = ha_mcs_impl_open(name, mode, test_if_locked);
}
catch (std::runtime_error& e)
{
current_thd->raise_error_printf(ER_INTERNAL_ERROR, e.what());
rc = ER_INTERNAL_ERROR;
}
DBUG_RETURN(rc); DBUG_RETURN(rc);
} }
@ -282,7 +319,16 @@ int ha_mcs::close(void)
{ {
DBUG_ENTER("ha_mcs::close"); DBUG_ENTER("ha_mcs::close");
int rc = ha_mcs_impl_close(); int rc;
try
{
rc = ha_mcs_impl_close();
}
catch (std::runtime_error& e)
{
current_thd->raise_error_printf(ER_INTERNAL_ERROR, e.what());
rc = ER_INTERNAL_ERROR;
}
DBUG_RETURN(rc); DBUG_RETURN(rc);
} }
@ -303,7 +349,16 @@ int ha_mcs::close(void)
int ha_mcs::write_row(const uchar* buf) int ha_mcs::write_row(const uchar* buf)
{ {
DBUG_ENTER("ha_mcs::write_row"); DBUG_ENTER("ha_mcs::write_row");
int rc = ha_mcs_impl_write_row(buf, table); int rc;
try
{
rc = ha_mcs_impl_write_row(buf, table);
}
catch (std::runtime_error& e)
{
current_thd->raise_error_printf(ER_INTERNAL_ERROR, e.what());
rc = ER_INTERNAL_ERROR;
}
DBUG_RETURN(rc); DBUG_RETURN(rc);
} }
@ -311,14 +366,30 @@ int ha_mcs::write_row(const uchar* buf)
void ha_mcs::start_bulk_insert(ha_rows rows, uint flags) void ha_mcs::start_bulk_insert(ha_rows rows, uint flags)
{ {
DBUG_ENTER("ha_mcs::start_bulk_insert"); DBUG_ENTER("ha_mcs::start_bulk_insert");
ha_mcs_impl_start_bulk_insert(rows, table); try
{
ha_mcs_impl_start_bulk_insert(rows, table);
}
catch (std::runtime_error& e)
{
current_thd->raise_error_printf(ER_INTERNAL_ERROR, e.what());
}
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
int ha_mcs::end_bulk_insert() int ha_mcs::end_bulk_insert()
{ {
DBUG_ENTER("ha_mcs::end_bulk_insert"); DBUG_ENTER("ha_mcs::end_bulk_insert");
int rc = ha_mcs_impl_end_bulk_insert(false, table); int rc;
try
{
rc = ha_mcs_impl_end_bulk_insert(false, table);
}
catch (std::runtime_error& e)
{
current_thd->raise_error_printf(ER_INTERNAL_ERROR, e.what());
rc = ER_INTERNAL_ERROR;
}
DBUG_RETURN(rc); DBUG_RETURN(rc);
} }
@ -339,7 +410,16 @@ int ha_mcs::update_row(const uchar* old_data, uchar* new_data)
{ {
DBUG_ENTER("ha_mcs::update_row"); DBUG_ENTER("ha_mcs::update_row");
int rc = ha_mcs_impl_update_row(); int rc;
try
{
rc = ha_mcs_impl_update_row();
}
catch (std::runtime_error& e)
{
current_thd->raise_error_printf(ER_INTERNAL_ERROR, e.what());
rc = ER_INTERNAL_ERROR;
}
DBUG_RETURN(rc); DBUG_RETURN(rc);
} }
@ -365,15 +445,33 @@ int ha_mcs::direct_update_rows_init(List<Item> *update_fields)
int ha_mcs::direct_update_rows(ha_rows *update_rows) int ha_mcs::direct_update_rows(ha_rows *update_rows)
{ {
DBUG_ENTER("ha_mcs::direct_update_rows"); DBUG_ENTER("ha_mcs::direct_update_rows");
int rc = ha_mcs_impl_direct_update_delete_rows(false, update_rows); int rc;
try
{
rc = ha_mcs_impl_direct_update_delete_rows(false, update_rows);
}
catch (std::runtime_error& e)
{
current_thd->raise_error_printf(ER_INTERNAL_ERROR, e.what());
rc = ER_INTERNAL_ERROR;
}
DBUG_RETURN(rc); DBUG_RETURN(rc);
} }
int ha_mcs::direct_update_rows(ha_rows *update_rows, ha_rows *found_rows) int ha_mcs::direct_update_rows(ha_rows *update_rows, ha_rows *found_rows)
{ {
DBUG_ENTER("ha_mcs::direct_update_rows"); DBUG_ENTER("ha_mcs::direct_update_rows");
int rc = ha_mcs_impl_direct_update_delete_rows(false, update_rows); int rc;
*found_rows = *update_rows; try
{
rc = ha_mcs_impl_direct_update_delete_rows(false, update_rows);
*found_rows = *update_rows;
}
catch (std::runtime_error& e)
{
current_thd->raise_error_printf(ER_INTERNAL_ERROR, e.what());
rc = ER_INTERNAL_ERROR;
}
DBUG_RETURN(rc); DBUG_RETURN(rc);
} }
@ -386,7 +484,16 @@ int ha_mcs::direct_delete_rows_init()
int ha_mcs::direct_delete_rows(ha_rows *deleted_rows) int ha_mcs::direct_delete_rows(ha_rows *deleted_rows)
{ {
DBUG_ENTER("ha_mcs::direct_delete_rows"); DBUG_ENTER("ha_mcs::direct_delete_rows");
int rc = ha_mcs_impl_direct_update_delete_rows(true, deleted_rows); int rc;
try
{
rc = ha_mcs_impl_direct_update_delete_rows(true, deleted_rows);
}
catch (std::runtime_error& e)
{
current_thd->raise_error_printf(ER_INTERNAL_ERROR, e.what());
rc = ER_INTERNAL_ERROR;
}
DBUG_RETURN(rc); DBUG_RETURN(rc);
} }
/** /**
@ -412,7 +519,16 @@ int ha_mcs::direct_delete_rows(ha_rows *deleted_rows)
int ha_mcs::delete_row(const uchar* buf) int ha_mcs::delete_row(const uchar* buf)
{ {
DBUG_ENTER("ha_mcs::delete_row"); DBUG_ENTER("ha_mcs::delete_row");
int rc = ha_mcs_impl_delete_row(); int rc;
try
{
rc = ha_mcs_impl_delete_row();
}
catch (std::runtime_error& e)
{
current_thd->raise_error_printf(ER_INTERNAL_ERROR, e.what());
rc = ER_INTERNAL_ERROR;
}
DBUG_RETURN(rc); DBUG_RETURN(rc);
} }
@ -511,7 +627,15 @@ int ha_mcs::rnd_init(bool scan)
int rc = 0; int rc = 0;
if(scan) if(scan)
{ {
rc = ha_mcs_impl_rnd_init(table); try
{
rc = ha_mcs_impl_rnd_init(table);
}
catch (std::runtime_error& e)
{
current_thd->raise_error_printf(ER_INTERNAL_ERROR, e.what());
rc = ER_INTERNAL_ERROR;
}
} }
DBUG_RETURN(rc); DBUG_RETURN(rc);
@ -521,7 +645,16 @@ int ha_mcs::rnd_end()
{ {
DBUG_ENTER("ha_mcs::rnd_end"); DBUG_ENTER("ha_mcs::rnd_end");
int rc = ha_mcs_impl_rnd_end(table); int rc;
try
{
rc = ha_mcs_impl_rnd_end(table);
}
catch (std::runtime_error& e)
{
current_thd->raise_error_printf(ER_INTERNAL_ERROR, e.what());
rc = ER_INTERNAL_ERROR;
}
DBUG_RETURN(rc); DBUG_RETURN(rc);
} }
@ -545,7 +678,16 @@ int ha_mcs::rnd_next(uchar* buf)
{ {
DBUG_ENTER("ha_mcs::rnd_next"); DBUG_ENTER("ha_mcs::rnd_next");
int rc = ha_mcs_impl_rnd_next(buf, table); int rc;
try
{
rc = ha_mcs_impl_rnd_next(buf, table);
}
catch (std::runtime_error& e)
{
current_thd->raise_error_printf(ER_INTERNAL_ERROR, e.what());
rc = ER_INTERNAL_ERROR;
}
DBUG_RETURN(rc); DBUG_RETURN(rc);
} }
@ -601,7 +743,16 @@ void ha_mcs::position(const uchar* record)
int ha_mcs::rnd_pos(uchar* buf, uchar* pos) int ha_mcs::rnd_pos(uchar* buf, uchar* pos)
{ {
DBUG_ENTER("ha_mcs::rnd_pos"); DBUG_ENTER("ha_mcs::rnd_pos");
int rc = ha_mcs_impl_rnd_pos(buf, pos); int rc;
try
{
rc = ha_mcs_impl_rnd_pos(buf, pos);
}
catch (std::runtime_error& e)
{
current_thd->raise_error_printf(ER_INTERNAL_ERROR, e.what());
rc = ER_INTERNAL_ERROR;
}
DBUG_RETURN(rc); DBUG_RETURN(rc);
} }
@ -754,11 +905,20 @@ int ha_mcs::external_lock(THD* thd, int lock_type)
{ {
DBUG_ENTER("ha_mcs::external_lock"); DBUG_ENTER("ha_mcs::external_lock");
//@Bug 2526 Only register the transaction when autocommit is off int rc;
if ((thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) try
trans_register_ha( thd, true, mcs_hton); {
//@Bug 2526 Only register the transaction when autocommit is off
if ((thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))
trans_register_ha( thd, true, mcs_hton);
int rc = ha_mcs_impl_external_lock(thd, table, lock_type); rc = ha_mcs_impl_external_lock(thd, table, lock_type);
}
catch (std::runtime_error& e)
{
current_thd->raise_error_printf(ER_INTERNAL_ERROR, e.what());
rc = ER_INTERNAL_ERROR;
}
DBUG_RETURN(rc); DBUG_RETURN(rc);
} }
@ -839,7 +999,17 @@ int ha_mcs::delete_table(const char* name)
DBUG_ENTER("ha_mcs::delete_table"); DBUG_ENTER("ha_mcs::delete_table");
/* This is not implemented but we want someone to be able that it works. */ /* This is not implemented but we want someone to be able that it works. */
int rc = ha_mcs_impl_delete_table(name); int rc;
try
{
rc = ha_mcs_impl_delete_table(name);
}
catch (std::runtime_error& e)
{
current_thd->raise_error_printf(ER_INTERNAL_ERROR, e.what());
rc = ER_INTERNAL_ERROR;
}
DBUG_RETURN(rc); DBUG_RETURN(rc);
} }
@ -862,7 +1032,16 @@ int ha_mcs::delete_table(const char* name)
int ha_mcs::rename_table(const char* from, const char* to) int ha_mcs::rename_table(const char* from, const char* to)
{ {
DBUG_ENTER("ha_mcs::rename_table "); DBUG_ENTER("ha_mcs::rename_table ");
int rc = ha_mcs_impl_rename_table(from, to); int rc;
try
{
rc = ha_mcs_impl_rename_table(from, to);
}
catch (std::runtime_error& e)
{
current_thd->raise_error_printf(ER_INTERNAL_ERROR, e.what());
rc = ER_INTERNAL_ERROR;
}
DBUG_RETURN(rc); DBUG_RETURN(rc);
} }
@ -912,14 +1091,32 @@ int ha_mcs::create(const char* name, TABLE* table_arg,
{ {
DBUG_ENTER("ha_mcs::create"); DBUG_ENTER("ha_mcs::create");
int rc = ha_mcs_impl_create(name, table_arg, create_info); int rc;
try
{
rc = ha_mcs_impl_create(name, table_arg, create_info);
}
catch (std::runtime_error& e)
{
current_thd->raise_error_printf(ER_INTERNAL_ERROR, e.what());
rc = ER_INTERNAL_ERROR;
}
DBUG_RETURN(rc); DBUG_RETURN(rc);
} }
const COND* ha_mcs::cond_push(const COND* cond) const COND* ha_mcs::cond_push(const COND* cond)
{ {
DBUG_ENTER("ha_mcs::cond_push"); DBUG_ENTER("ha_mcs::cond_push");
DBUG_RETURN(ha_mcs_impl_cond_push(const_cast<COND*>(cond), table)); COND* ret_cond = NULL;
try
{
ret_cond = ha_mcs_impl_cond_push(const_cast<COND*>(cond), table);
}
catch (std::runtime_error& e)
{
current_thd->raise_error_printf(ER_INTERNAL_ERROR, e.what());
}
DBUG_RETURN(ret_cond);
} }

View File

@ -28,7 +28,7 @@ extern handlerton* mcs_hton;
COLUMNSTORE_SHARE is a structure that will be shared among all open handlers. COLUMNSTORE_SHARE is a structure that will be shared among all open handlers.
This example implements the minimum of what you will probably need. This example implements the minimum of what you will probably need.
*/ */
typedef struct st_calpont_share typedef struct st_mcs_share
{ {
char* table_name; char* table_name;
uint32_t table_name_length, use_count; uint32_t table_name_length, use_count;

View File

@ -93,7 +93,19 @@ static int generate_result(BRM::OID_t oid, BRM::DBRM* emp, TABLE* table, THD* th
char oidDirName[WriteEngine::FILE_NAME_SIZE]; char oidDirName[WriteEngine::FILE_NAME_SIZE];
char fullFileName[WriteEngine::FILE_NAME_SIZE]; char fullFileName[WriteEngine::FILE_NAME_SIZE];
char dbDir[WriteEngine::MAX_DB_DIR_LEVEL][WriteEngine::MAX_DB_DIR_NAME_SIZE]; char dbDir[WriteEngine::MAX_DB_DIR_LEVEL][WriteEngine::MAX_DB_DIR_NAME_SIZE];
config::Config* config = config::Config::makeConfig();
config::Config* config;
try
{
config = config::Config::makeConfig();
}
catch (std::runtime_error& e)
{
thd->raise_error_printf(ER_INTERNAL_ERROR, e.what());
return ER_INTERNAL_ERROR;
}
WriteEngine::Config we_config; WriteEngine::Config we_config;
off_t fileSize = 0; off_t fileSize = 0;
off_t compressedFileSize = 0; off_t compressedFileSize = 0;

View File

@ -114,19 +114,17 @@ Config* Config::makeConfig(const char* cf)
Config::Config(const string& configFile) : Config::Config(const string& configFile) :
fDoc(0), fConfigFile(configFile), fMtime(0), fParser() fDoc(0), fConfigFile(configFile), fMtime(0), fParser()
{ {
for ( int i = 0 ; i < 20 ; i++ ) int i = 0;
for ( ; i < 2 ; i++ )
{ {
if (access(fConfigFile.c_str(), R_OK) != 0) if (access(fConfigFile.c_str(), R_OK) == 0)
{
if ( i >= 15 )
throw runtime_error("Config::Config: error accessing config file " + fConfigFile);
sleep (1);
}
else
break; break;
sleep (1);
} }
if ( i == 2 )
throw runtime_error("Config::Config: error accessing config file " + fConfigFile);
struct stat statbuf; struct stat statbuf;
if (stat(configFile.c_str(), &statbuf) == 0) if (stat(configFile.c_str(), &statbuf) == 0)