1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-29 08:21:15 +03:00

MCOL-520 - initial changes for /dev/shm

This commit is contained in:
David Hill
2018-10-01 14:39:17 -05:00
parent 05bcd58e76
commit 8d3ce9757f
6 changed files with 68 additions and 12 deletions

View File

@ -191,6 +191,12 @@ mkdir -p $hdfsDir >/dev/null 2>&1
#create mount directories #create mount directories
mkdir /mnt/tmp > /dev/null 2>&1 mkdir /mnt/tmp > /dev/null 2>&1
#create shared memory if non-root
if [ $user != "root" ]; then
mkdir -p ${installdir}/dev/shm
chmod 666 ${installdir}/dev/shm
fi
# remove mysql archive log # remove mysql archive log
test -d $installdir/mysql/db || mkdir -p $installdir/mysql/db test -d $installdir/mysql/db || mkdir -p $installdir/mysql/db
rm -rf $installdir/mysql/db/columnstore_log_archive > /dev/null 2>&1 rm -rf $installdir/mysql/db/columnstore_log_archive > /dev/null 2>&1

View File

@ -852,7 +852,7 @@ int main(int argc, char* argv[])
if (temp == "1") if (temp == "1")
{ {
singleServerInstall = temp; singleServerInstall = temp;
cout << endl << "Performing the Single Server Install." << endl; cout << endl << "Performing the Single Server Install." << endl << endl;
if ( reuseConfig == "n" ) if ( reuseConfig == "n" )
{ {

View File

@ -1886,6 +1886,11 @@ static void statusControlThread()
// //
//Allocate Shared Memory for storing Process Status Data //Allocate Shared Memory for storing Process Status Data
// //
string shmLocation = "/dev/shm/";
if ( !rootUser)
shmLocation = startup::StartUp::installDir() + "/dev/shm/";
PROCSTATshmsize = MAX_PROCESS * sizeof(shmProcessStatus); PROCSTATshmsize = MAX_PROCESS * sizeof(shmProcessStatus);
bool memInit = true; bool memInit = true;
#if 0 #if 0
@ -1914,7 +1919,7 @@ static void statusControlThread()
bi::shared_memory_object shm(bi::create_only, keyName.c_str(), bi::read_write); bi::shared_memory_object shm(bi::create_only, keyName.c_str(), bi::read_write);
#ifdef __linux__ #ifdef __linux__
{ {
string pname = "/dev/shm/" + keyName; string pname = shmLocation + keyName;
chmod(pname.c_str(), 0666); chmod(pname.c_str(), 0666);
} }
#endif #endif
@ -1992,7 +1997,7 @@ static void statusControlThread()
bi::shared_memory_object shm(bi::create_only, keyName.c_str(), bi::read_write); bi::shared_memory_object shm(bi::create_only, keyName.c_str(), bi::read_write);
#ifdef __linux__ #ifdef __linux__
{ {
string pname = "/dev/shm/" + keyName; string pname = shmLocation + keyName;
chmod(pname.c_str(), 0666); chmod(pname.c_str(), 0666);
} }
#endif #endif
@ -2111,7 +2116,7 @@ static void statusControlThread()
bi::shared_memory_object shm(bi::create_only, keyName.c_str(), bi::read_write); bi::shared_memory_object shm(bi::create_only, keyName.c_str(), bi::read_write);
#ifdef __linux__ #ifdef __linux__
{ {
string pname = "/dev/shm/" + keyName; string pname = shmLocation + keyName;
chmod(pname.c_str(), 0666); chmod(pname.c_str(), 0666);
} }
#endif #endif
@ -2209,7 +2214,7 @@ static void statusControlThread()
bi::shared_memory_object shm(bi::create_only, keyName.c_str(), bi::read_write); bi::shared_memory_object shm(bi::create_only, keyName.c_str(), bi::read_write);
#ifdef __linux__ #ifdef __linux__
{ {
string pname = "/dev/shm/" + keyName; string pname = shmLocation + keyName;
chmod(pname.c_str(), 0666); chmod(pname.c_str(), 0666);
} }
#endif #endif
@ -2299,7 +2304,7 @@ static void statusControlThread()
bi::shared_memory_object shm(bi::create_only, keyName.c_str(), bi::read_write); bi::shared_memory_object shm(bi::create_only, keyName.c_str(), bi::read_write);
#ifdef __linux__ #ifdef __linux__
{ {
string pname = "/dev/shm/" + keyName; string pname = shmLocation + keyName;
chmod(pname.c_str(), 0666); chmod(pname.c_str(), 0666);
} }
#endif #endif

View File

@ -52,6 +52,8 @@ using namespace boost::posix_time;
#include "shmkeys.h" #include "shmkeys.h"
#include "installdir.h"
namespace namespace
{ {
using namespace rwlock; using namespace rwlock;
@ -141,13 +143,26 @@ RWLockShmImpl::RWLockShmImpl(int key, bool excl)
string keyName = BRM::ShmKeys::keyToName(key); string keyName = BRM::ShmKeys::keyToName(key);
fKeyString = keyName; fKeyString = keyName;
bool rootUser = true;
//check if root-user
int user;
user = getuid();
if (user != 0)
rootUser = false;
string shmLocation = "/dev/shm/";
if ( !rootUser)
shmLocation = startup::StartUp::installDir() + "/dev/shm/";
try try
{ {
#if BOOST_VERSION < 104500 #if BOOST_VERSION < 104500
bi::shared_memory_object shm(bi::create_only, keyName.c_str(), bi::read_write); bi::shared_memory_object shm(bi::create_only, keyName.c_str(), bi::read_write);
#ifdef __linux__ #ifdef __linux__
{ {
string pname = "/dev/shm/" + keyName; string pname = shmLocation + keyName;
chmod(pname.c_str(), 0666); chmod(pname.c_str(), 0666);
} }
#endif #endif

View File

@ -36,6 +36,8 @@ namespace bi = boost::interprocess;
#include "brmshmimpl.h" #include "brmshmimpl.h"
#include "brmtypes.h" #include "brmtypes.h"
#include "installdir.h"
namespace BRM namespace BRM
{ {
@ -44,6 +46,19 @@ BRMShmImpl::BRMShmImpl(unsigned key, off_t size, bool readOnly) :
{ {
string keyName = ShmKeys::keyToName(fKey); string keyName = ShmKeys::keyToName(fKey);
bool rootUser = true;
//check if root-user
int user;
user = getuid();
if (user != 0)
rootUser = false;
string shmLocation = "/dev/shm/";
if ( !rootUser)
shmLocation = startup::StartUp::installDir() + "/dev/shm/";
if (fSize == 0) if (fSize == 0)
{ {
unsigned tries = 0; unsigned tries = 0;
@ -89,7 +104,7 @@ again:
bi::shared_memory_object shm(bi::create_only, keyName.c_str(), bi::read_write); bi::shared_memory_object shm(bi::create_only, keyName.c_str(), bi::read_write);
#ifdef __linux__ #ifdef __linux__
{ {
string pname = "/dev/shm/" + keyName; string pname = "shmLocation + keyName;
chmod(pname.c_str(), 0666); chmod(pname.c_str(), 0666);
} }
#endif #endif
@ -147,7 +162,7 @@ int BRMShmImpl::grow(unsigned newKey, off_t newSize)
bi::shared_memory_object shm(bi::create_only, keyName.c_str(), bi::read_write); bi::shared_memory_object shm(bi::create_only, keyName.c_str(), bi::read_write);
#ifdef __linux__ #ifdef __linux__
{ {
string pname = "/dev/shm/" + keyName; string pname = shmLocation + keyName;
chmod(pname.c_str(), 0666); chmod(pname.c_str(), 0666);
} }
#endif #endif
@ -194,7 +209,7 @@ int BRMShmImpl::clear(unsigned newKey, off_t newSize)
bi::shared_memory_object shm(bi::create_only, keyName.c_str(), bi::read_write); bi::shared_memory_object shm(bi::create_only, keyName.c_str(), bi::read_write);
#ifdef __linux__ #ifdef __linux__
{ {
string pname = "/dev/shm/" + keyName; string pname = shmLocation + keyName;
chmod(pname.c_str(), 0666); chmod(pname.c_str(), 0666);
} }
#endif #endif

View File

@ -41,6 +41,8 @@ using namespace rwlock;
#include "mastersegmenttable.h" #include "mastersegmenttable.h"
#undef MASTERSEGMENTTABLE_DLLEXPORT #undef MASTERSEGMENTTABLE_DLLEXPORT
#include "installdir.h"
namespace namespace
{ {
using namespace BRM; using namespace BRM;
@ -73,13 +75,26 @@ MasterSegmentTableImpl::MasterSegmentTableImpl(int key, int size)
{ {
string keyName = ShmKeys::keyToName(key); string keyName = ShmKeys::keyToName(key);
bool rootUser = true;
//check if root-user
int user;
user = getuid();
if (user != 0)
rootUser = false;
string shmLocation = "/dev/shm/";
if ( !rootUser)
shmLocation = startup::StartUp::installDir() + "/dev/shm/";
try try
{ {
#if BOOST_VERSION < 104500 #if BOOST_VERSION < 104500
bi::shared_memory_object shm(bi::create_only, keyName.c_str(), bi::read_write); bi::shared_memory_object shm(bi::create_only, keyName.c_str(), bi::read_write);
#ifdef __linux__ #ifdef __linux__
{ {
string pname = "/dev/shm/" + keyName; string pname = shmLocation + keyName;
chmod(pname.c_str(), 0666); chmod(pname.c_str(), 0666);
} }
#endif #endif
@ -96,7 +111,7 @@ MasterSegmentTableImpl::MasterSegmentTableImpl(int key, int size)
bi::shared_memory_object shm(bi::open_only, keyName.c_str(), bi::read_write); bi::shared_memory_object shm(bi::open_only, keyName.c_str(), bi::read_write);
#ifdef __linux__ #ifdef __linux__
{ {
string pname = "/dev/shm/" + keyName; string pname = shmLocation + keyName;
chmod(pname.c_str(), 0666); chmod(pname.c_str(), 0666);
} }
#endif #endif