From 5ac29cd577b7b6fa6b1f8fe178be2692a49918e0 Mon Sep 17 00:00:00 2001 From: prabatuty Date: Mon, 26 Oct 2009 10:46:12 +0000 Subject: [PATCH] csqlcacheserver reconnect, logger rotate, monitor_server --- csql.conf | 3 ++ include/Config.h | 5 ++-- include/ErrorType.h | 3 +- include/os.h | 1 + src/adapter/SqlOdbcConnection.cxx | 9 ++++-- src/adapter/SqlOdbcStatement.cxx | 11 ++++++- src/cache/CacheTableLoader.cxx | 24 ++++++++------- src/storage/Config.cxx | 4 ++- src/storage/Logger.cxx | 61 ++++++++++++++++++++++----------------- src/tools/csqlcacheserver.cxx | 50 +++++++++++++++++++++++++++----- src/tools/csqlserver.cxx | 49 +++++++++++++++++-------------- 11 files changed, 149 insertions(+), 71 deletions(-) diff --git a/csql.conf b/csql.conf index 4bffd8cb..9f484e87 100644 --- a/csql.conf +++ b/csql.conf @@ -63,6 +63,9 @@ DATABASE_FILE=/tmp/csql/db # Give full path for the std error file to store all the errors during database operations STDERR_FILE=stderr +#Restarts auxillary servers (SQL, Cache,etc), if they crash +MONITOR_SERVERS=false + #####################################Client Section######################## #Mutex timeout interval seconds diff --git a/include/Config.h b/include/Config.h index d3ab3d86..7a1c6a8e 100644 --- a/include/Config.h +++ b/include/Config.h @@ -71,6 +71,7 @@ class ConfigValues int noOfProcessors; int stmtCacheSize; bool isCacheNoParam; + bool isMonitor; ConfigValues() @@ -121,7 +122,7 @@ class ConfigValues noOfProcessors = 1; stmtCacheSize = 10; isCacheNoParam = false; - + isMonitor = false; } }; @@ -178,7 +179,7 @@ class Config inline int getNoOfProcessors() { return cVal.noOfProcessors; } inline int getStmtCacheSize() { return cVal.stmtCacheSize; } inline bool useCacheNoParam() { return cVal.isCacheNoParam; } - + inline bool useMonitorServers() { return cVal.isMonitor; } }; class Conf diff --git a/include/ErrorType.h b/include/ErrorType.h index 4a25e946..6315d877 100644 --- a/include/ErrorType.h +++ b/include/ErrorType.h @@ -16,7 +16,6 @@ enum DbRetVal { - ErrNullValues = 1, //used in evaluate on null values OK = 0, /**< OK. No error. Operation succeded. */ ErrSysFatal = -1, ErrSysInit = -2, @@ -53,7 +52,9 @@ enum DbRetVal ErrAutoIncUpdate = -33, ErrForeignKeyInsert=-34, ErrForeignKeyDelete=-35, + ErrNullValues =-36, //used in evaluate on null values // add new error type here + ErrNote = -97, ErrUnknown = -98, ErrWarning = -99, SplCase = -100 diff --git a/include/os.h b/include/os.h index 873047fc..80c14631 100644 --- a/include/os.h +++ b/include/os.h @@ -34,6 +34,7 @@ #include #include #include +#include #if defined(SOLARIS) #include #include diff --git a/src/adapter/SqlOdbcConnection.cxx b/src/adapter/SqlOdbcConnection.cxx index 27f0f6f1..238d9db8 100644 --- a/src/adapter/SqlOdbcConnection.cxx +++ b/src/adapter/SqlOdbcConnection.cxx @@ -256,9 +256,9 @@ DbRetVal SqlOdbcConnection::connect (char *user, char * pass) } while( ret == SQL_SUCCESS ); rv = ErrNoConnection; - rv = OK; //masking the error:tmp + //rv = OK; //masking the error:tmp } - //printError(ErrSysInit, "Connecting with dsn=%s\n", dsn); + logFine(Conf::logger, "Connecting with dsn=%s\n", dsn); (*ODBCFuncPtrs.SQLSetConnectAttrPtr)(dbHdl, SQL_ATTR_AUTOCOMMIT, SQL_AUTOCOMMIT_OFF, 0); return rv; @@ -270,6 +270,7 @@ DbRetVal SqlOdbcConnection::disconnect() (*ODBCFuncPtrs.SQLDisconnectPtr)(dbHdl); (*ODBCFuncPtrs.SQLFreeHandlePtr) (SQL_HANDLE_DBC, dbHdl); (*ODBCFuncPtrs.SQLFreeHandlePtr) (SQL_HANDLE_ENV, envHdl); + logFine(Conf::logger, "disconnected"); return rv; } void SqlOdbcConnection::setTrDbName(char *name) @@ -319,6 +320,8 @@ DbRetVal SqlOdbcConnection::commit() int retVal=0; retVal = (*ODBCFuncPtrs.SQLTransactPtr)(envHdl, dbHdl, SQL_COMMIT); if (!SQL_SUCCEEDED(retVal)) rv = ErrSysInit; + else + logFinest(Conf::logger, "Transaction Committed"); return rv; } DbRetVal SqlOdbcConnection::rollback() @@ -327,6 +330,8 @@ DbRetVal SqlOdbcConnection::rollback() int retVal =0; retVal = (*ODBCFuncPtrs.SQLTransactPtr)(envHdl, dbHdl, SQL_ROLLBACK); if (!SQL_SUCCEEDED(retVal)) rv = ErrSysInit; + else + logFinest(Conf::logger, "Transaction Rollback"); return rv; } void SqlOdbcConnection::setErrorState( SQLHDBC dbc) diff --git a/src/adapter/SqlOdbcStatement.cxx b/src/adapter/SqlOdbcStatement.cxx index 22bbef65..b5bc7cc7 100644 --- a/src/adapter/SqlOdbcStatement.cxx +++ b/src/adapter/SqlOdbcStatement.cxx @@ -33,6 +33,7 @@ DbRetVal SqlOdbcStatement::executeDirect(char *stmtstr) SQLCHAR* sstr= (SQLCHAR*)stmtstr; retValue=(*SqlOdbcConnection::ODBCFuncPtrs.SQLExecDirectPtr) (hstmt, sstr, SQL_NTS); if (retValue) return ErrBadCall; + logFinest(Conf::logger, "executeDirect %s", stmtstr); return rv; } @@ -53,12 +54,14 @@ DbRetVal SqlOdbcStatement::prepare(char *stmtstr) retValue = (*SqlOdbcConnection::ODBCFuncPtrs.SQLPreparePtr) (hstmt, sstr, SQL_NTS); if (retValue) { // setErrorState(hstmt); - return ErrBadCall; + printError(ErrSysInternal, "Unable to prepare statement"); + return ErrSysInternal; } isSelStmt=chechStmtType(stmtstr); isPrepared = true; if(strstr(stmtstr,"call ")!=NULL || strstr(stmtstr,"CALL ")!=NULL) { + logFinest(Conf::logger, "Procedure call statement =true"); isProcedureCallStmt=true; } short totalFields=0; @@ -77,6 +80,7 @@ DbRetVal SqlOdbcStatement::prepare(char *stmtstr) SWORD cType=0; SQLULEN cLength=0; scale=0; + logFinest(Conf::logger, "NumParams %d", totalFields); if(totalFields != 0) { paramlen =(SQLINTEGER *) malloc((totalFields+1)*sizeof(SQLINTEGER)); @@ -129,6 +133,7 @@ DbRetVal SqlOdbcStatement::prepare(char *stmtstr) } //TODO::deallocate memory and remove elements from list in case of any //failure in any of the above ODBC functions + logFinest(Conf::logger, "Statement prepared %s", stmtstr); return OK; } @@ -199,12 +204,14 @@ DbRetVal SqlOdbcStatement::execute(int &rowsAffected) } rv = resolveForBindField(hstmt); if(rv!=OK) return rv; + logFinest(Conf::logger, "Procedure executed"); }else{ retValue = (*SqlOdbcConnection::ODBCFuncPtrs.SQLExecutePtr) (hstmt); if ((retValue != SQL_SUCCESS) && (retValue != SQL_SUCCESS_WITH_INFO )) { // setErrorState(hstmt); return ErrBadCall; } + logFinest(Conf::logger, "Statement executed"); } //retValue=SQLRowCount(hstmt,(SQLINTEGER*)&rowsAffected); retValue= (*SqlOdbcConnection::ODBCFuncPtrs.SQLRowCountPtr)(hstmt,(SQLINTEGER*)&rowsAffected); @@ -421,6 +428,7 @@ DbRetVal SqlOdbcStatement::close() { if (!isPrepared) return OK; (*SqlOdbcConnection::ODBCFuncPtrs.SQLCloseCursorPtr)(hstmt); + logFinest(Conf::logger, "CloseCursor"); return OK; } bool SqlOdbcStatement::chechStmtType(char *buf) @@ -590,6 +598,7 @@ DbRetVal SqlOdbcStatement::free() (*SqlOdbcConnection::ODBCFuncPtrs.SQLFreeHandlePtr)(SQL_HANDLE_STMT, hstmt); isPrepared = false; isProcedureCallStmt = false; + logFinest(Conf::logger, "Statement Freed"); return OK; } void SqlOdbcStatement::setShortParam(int paramPos, short value) diff --git a/src/cache/CacheTableLoader.cxx b/src/cache/CacheTableLoader.cxx index 0ffcd219..34a97988 100644 --- a/src/cache/CacheTableLoader.cxx +++ b/src/cache/CacheTableLoader.cxx @@ -135,8 +135,7 @@ DbRetVal CacheTableLoader::load(AbsSqlConnection *conn, AbsSqlStatement *stmt, b else if (strcasecmp(tdb,"postgres")==0) tdbName=mysql; else printError(ErrNotFound,"Target Database Name is not properly set.Tdb name could be mysql, postgres, sybase, db2, oracle\n"); - //ENDs Here: - + logFine(Conf::logger, "TDB Name:%s\n", tdb); //DatabaseManager *dbMgr = (DatabaseManager *) conn->getDatabaseManager(); //char dsn[72]; @@ -198,6 +197,7 @@ DbRetVal CacheTableLoader::load(AbsSqlConnection *conn, AbsSqlStatement *stmt, b printError(ErrSysInit, "Unable to Prepare ODBC statement \n"); return ErrSysInit; } + logFinest(Conf::logger, "Cache Table Stmt %s", stmtBuf); if (tabDefinition) { short totalFields=0; retValue = SQLNumResultCols (hstmt, &totalFields); @@ -278,7 +278,7 @@ DbRetVal CacheTableLoader::load(AbsSqlConnection *conn, AbsSqlStatement *stmt, b (strcmp(fieldlistVal,"")!=0) && (strcmp(fieldlistVal,"NULL")!=0)) { - printError(ErrSysInit, "Bidirectonal caching should have primary key in %s \n", tableName); + printError(ErrSysInit, "Bidirectional caching should have primary key in %s \n", tableName); SQLFreeHandle (SQL_HANDLE_STMT, hstmtmeta); SQLFreeHandle (SQL_HANDLE_STMT, hstmt); SQLDisconnect (hdbc); @@ -292,7 +292,7 @@ DbRetVal CacheTableLoader::load(AbsSqlConnection *conn, AbsSqlStatement *stmt, b { if(Conf::config.useTwoWayCache()) { - printError(ErrSysInit, "Bidirectonal caching fail for no primary key in %s \n", tableName); + printError(ErrSysInit, "Bidirectional caching fail for no primary key in %s \n", tableName); SQLFreeHandle (SQL_HANDLE_STMT, hstmtmeta); SQLFreeHandle (SQL_HANDLE_STMT, hstmt); SQLDisconnect (hdbc); @@ -336,7 +336,9 @@ DbRetVal CacheTableLoader::load(AbsSqlConnection *conn, AbsSqlStatement *stmt, b return ErrSysInit; } Util::str_tolower((char*)colName); - printDebug(DM_Gateway, "Describe Column %s %d %d \n", colName, colType, colLength); + printDebug(DM_Gateway, "Describe Column %s %d %d %d %d \n", colName, colType, colLength, scale, nullable); + logFinest(Conf::logger, "Describe Column colName:%s colType:%d colLen:%d scale:%d nullable:%d\n", colName, colType, colLength, scale, nullable); + icol++; if(strcmp((char*)colName,fieldName)== 0) { @@ -468,7 +470,7 @@ DbRetVal CacheTableLoader::load(AbsSqlConnection *conn, AbsSqlStatement *stmt, b delete inf; return ErrSysInit; } - //printf("Table created from create table stmt\n"); + logFinest(Conf::logger, "Cache Table: Table Created :%s", crtTblStmt); //Table is created. //Create primary key index if present @@ -812,7 +814,7 @@ DbRetVal CacheTableLoader::unload(bool tabDefinition) if (dbMgr == NULL) { conn->disconnect(); delete stmt; delete conn; - printError(ErrSysInit, "Auth failed\n"); + printError(ErrSysInit, "Authentication failed\n"); return ErrSysInit; } if (!tabDefinition) @@ -863,6 +865,7 @@ DbRetVal CacheTableLoader::unload(bool tabDefinition) } conn->disconnect(); delete stmt; delete conn; + logFine(Conf::logger, "Unloaded Cached Table: %s", tableName); return rv; } @@ -909,7 +912,7 @@ DbRetVal CacheTableLoader::recoverAllCachedTables() //continue; printDebug(DM_Gateway, "Recovering Table from target db: %s\n", tablename); setCondition(TableConf::config.getRealConditionFromFile(condition)); - if( (strcmp(Conf::config.getDSN(),dsnname)!=0) ){ + if( (strcmp(Conf::config.getDSN(),dsnname)!=0) ){ setDsnName(dsnname); setTable(tablename); setFieldName(fieldname); @@ -917,7 +920,7 @@ DbRetVal CacheTableLoader::recoverAllCachedTables() printf("Recovering table %s %s %s\n", tablename,condition,field); rv = load(); if (rv != OK) { fclose(fp); return rv; } - } else { + } else { setDsnName(Conf::config.getDSN()); setTable(tablename); setFieldName(fieldname); @@ -925,7 +928,8 @@ DbRetVal CacheTableLoader::recoverAllCachedTables() printf("Recovering table %s %s %s\n", tablename,condition,field); rv = load(); if (rv != OK) { fclose(fp); return rv; } - } + } + logFine(Conf::logger, "Recovering Table from target db:%s", tablename); } fclose(fp); return OK; diff --git a/src/storage/Config.cxx b/src/storage/Config.cxx index c0fb3043..fa1a1122 100644 --- a/src/storage/Config.cxx +++ b/src/storage/Config.cxx @@ -118,6 +118,9 @@ int Config::storeKeyVal(char *key, char *value) { cVal.stmtCacheSize = atoi(value); } else if (os::strcasestr(key, "STMT_CACHE_NOPARAM") != NULL) { cVal.isCacheNoParam = os::atobool(value); } + else if (os::strcasestr(key, "MONITOR_SERVERS") != NULL) + { cVal.isMonitor = os::atobool(value); } + else return 1; return 0; @@ -351,7 +354,6 @@ int Config::readAllValues(char *fileName) } cVal.noOfProcessors = os::getNoOfProcessors(); isLoaded = true; - logConfig(); return 0; } void Config::logConfig() diff --git a/src/storage/Logger.cxx b/src/storage/Logger.cxx index 901475b5..c3179e7d 100644 --- a/src/storage/Logger.cxx +++ b/src/storage/Logger.cxx @@ -40,37 +40,37 @@ void Logger::rollOverIfRequired() { char *fileName = Conf::config.getLogFile(); int fileSize = os::getFileSize(fileName); + if (fileSize < LOG_ROLLOVER_SIZE) return ; char cmd[MAX_FILE_LEN]; int ret =0; - int tries=0, totalTries=Conf::config.getMutexRetries(); - while (tries < totalTries) { - ret = os::lockFile(fdLog); - if (ret ==0) break; - os::usleep(10000); - tries++; - } - if (tries == totalTries) - { - printError(ErrLockTimeOut,"Unable to lock log file for rollover"); - return ; - } + int tries=0, totalTries=Conf::config.getMutexRetries(); + while (tries < totalTries) { + ret = os::lockFile(fdLog); + if (ret ==0) break; + os::usleep(10000); + tries++; + } + if (tries == totalTries) + { + printError(ErrLockTimeOut,"Unable to lock log file for rollover %d",fdLog); + return ; + } - if (fileSize > LOG_ROLLOVER_SIZE) { - time_t cnow = ::time(NULL); + time_t cnow = ::time(NULL); #ifdef SOLARIS - struct std::tm *tmval = localtime(&cnow); + struct std::tm *tmval = localtime(&cnow); #else - struct tm *tmval = localtime(&cnow); + struct tm *tmval = localtime(&cnow); #endif - sprintf(cmd, "cp %s %s.%d-%d-%d:%d:%d:%d", fileName, fileName, - tmval->tm_year+1900, - tmval->tm_mon+1, tmval->tm_mday, tmval->tm_hour, - tmval->tm_min, tmval->tm_sec); - ret = system(cmd); - if (ret != 0) { - printError(ErrWarning, "Unable to rollover the log file"); - } - truncate(fileName, 0); + sprintf(cmd, "cp %s %s.%d-%d-%d:%d:%d:%d", fileName, fileName, + tmval->tm_year+1900, + tmval->tm_mon+1, tmval->tm_mday, tmval->tm_hour, + tmval->tm_min, tmval->tm_sec); + ret = system(cmd); + if (ret != 0) { + printError(ErrWarning, "Unable to rollover the log file"); + }else { + truncate(fileName, 0); } os::unlockFile(fdLog); return; @@ -99,6 +99,15 @@ int Logger::log(LogLevel level, char* filename, while (tries < totalTries) { ret = os::lockFile(fdLog); if (ret ==0) break; + if (ret !=0 && errno == EBADF) { + fdLog = os::openFile(filename, fileOpenAppend,0); + if (fdLog == -1) + { + printError(ErrSysInit,"Unable to open log file"); + delete[] buffer; + return ErrSysInit; + } + } os::usleep(10000); tries++; } @@ -111,7 +120,7 @@ int Logger::log(LogLevel level, char* filename, int bytesWritten = os::write(fdLog, buffer, strlen(buffer)); if (bytesWritten != strlen(buffer)) { - printf("Unable to write log entry"); + printError(ErrSysInternal, "Unable to write log entry"); ret = -1; } os::unlockFile(fdLog); diff --git a/src/tools/csqlcacheserver.cxx b/src/tools/csqlcacheserver.cxx index b16b0b61..07c569ad 100644 --- a/src/tools/csqlcacheserver.cxx +++ b/src/tools/csqlcacheserver.cxx @@ -100,14 +100,18 @@ int main(int argc, char **argv) SqlLogConnection *logConn = (SqlLogConnection *) csqlcon; logConn->setNoMsgLog(true); rv = csqlcon->connect(I_USER, I_PASS); - if (rv != OK) return NULL; + if (rv != OK) { + printError(ErrSysInternal, "Unable to connect to CSQL"); + return 1; + } // Reading "csqlds.conf file" FILE *fp = NULL; fp = fopen(Conf::config.getDsConfigFile(),"r"); if(fp==NULL){ printError(ErrSysInit,"csqlds.conf file does not exist"); - exit(1); + csqlcon->disconnect(); + return 1; } struct MultiThreadDSN *head=NULL, *pnode=NULL; @@ -132,6 +136,22 @@ int main(int argc, char **argv) else { pnode->next=multiDsn; pnode=pnode->next; } } fclose(fp); + if (totalDsn == 1) + { + + MultiDsnThread *info = new MultiDsnThread(); + strcpy(info->ds,pnode->dsn); + strcpy(info->targetDb,pnode->tdb); + strcpy(info->userName,pnode->user); + strcpy(info->pwdName,pnode->pwd); + startThread(info); + printf("Cache Server Exiting\n"); + cacheTableList.reset(); + csqlcon->disconnect(); + return 0; + } + + // Declare number of thread pthread_t *thrId =new pthread_t [totalDsn]; @@ -189,8 +209,23 @@ void *startThread(void *thrInfo) targetconn = SqlFactory::createConnection(CSqlAdapter); SqlOdbcConnection *dsnAda = (SqlOdbcConnection*)targetconn; dsnAda->setDsn(multiDsnInput->ds);//line added - rv = targetconn->connect(I_USER, I_PASS); - if (rv != OK) return NULL; + + struct timeval timeout, tval; + timeout.tv_sec = Conf::config.getCacheWaitSecs(); + timeout.tv_usec = 0; +reconnect: + while(!srvStop) { + rv = targetconn->connect(I_USER, I_PASS); + if (rv != OK) { + printError(ErrSysInternal, "Unable to connect to target database:%s", multiDsnInput->ds); + tval.tv_sec = timeout.tv_sec; + tval.tv_usec = timeout.tv_usec; + os::select(0, 0, 0, 0, &tval); + } else break; + if (srvStop) return NULL; + } + if (srvStop) return NULL; + if (!Conf::config.useCache()) { printf("Cache is set to OFF in csql.conf file\n"); @@ -204,7 +239,6 @@ void *startThread(void *thrInfo) int ret = 0; struct stat ofstatus,nfstatus; ret=stat(Conf::config.getTableConfigFile(),&ofstatus); - struct timeval timeout, tval; timeout.tv_sec = Conf::config.getCacheWaitSecs(); timeout.tv_usec = 0; createCacheTableList(); @@ -223,6 +257,8 @@ void *startThread(void *thrInfo) } if((ret = getRecordsFromTargetDb( targetconn, csqlcon, csqlstmt, con, sqlstmt )) == 1) { if (srvStop) break; + targetconn->disconnect(); + goto reconnect; } } @@ -269,7 +305,7 @@ int getRecordsFromTargetDb(AbsSqlConnection *targetconn, AbsSqlConnection *csqlc delstmt->free(); delete stmt; delete delstmt; - printf("FAILED\n"); + printError(ErrSysInternal, "Statement prepare failed. TDB may be down"); return 1; } int retVal =0; @@ -289,7 +325,7 @@ int getRecordsFromTargetDb(AbsSqlConnection *targetconn, AbsSqlConnection *csqlc while ( stmt->fetch() != NULL) { Util::trimEnd(tablename); - printf("Row value is %s %lld %lld %lld\n", tablename, pkid, op,cId); + logFiner(Conf::logger, "Row value is Table:%s PK:%lld OP:%lld CID:%lld\n", tablename, pkid, op,cId); if (op == 2) { //DELETE retVal = remove(tablename,pkid, targetconn, csqlstmt, csqlcon); diff --git a/src/tools/csqlserver.cxx b/src/tools/csqlserver.cxx index 7b901841..b3792e88 100644 --- a/src/tools/csqlserver.cxx +++ b/src/tools/csqlserver.cxx @@ -22,19 +22,19 @@ #include #include #include -#include //TODO::move this to os.h char* version = "csql-linux-i686-3.0GA"; int srvStop =0; pid_t asyncpid=0; pid_t sqlserverpid=0; pid_t cachepid=0; bool recoverFlag=false; -void dumpData(); +bool monitorServer= false; SessionImpl *session = NULL; static void sigTermHandler(int sig) { printf("Received signal %d\nStopping the server\n", sig); srvStop = 1; + monitorServer=false; } static void sigChildHandler(int sig) { @@ -345,7 +345,7 @@ int main(int argc, char **argv) } } } - bool isCacheReq = false, isSQLReq= false; + bool isCacheReq = false, isSQLReq= false, isAsyncReq=false; recoverFlag = true; if (opt == 1 && isInit && ! Conf::config.useDurability()) { if (Conf::config.useCache()) { @@ -377,6 +377,7 @@ int main(int argc, char **argv) Conf::config.getCacheMode()==ASYNC_MODE)) { int msgid = os::msgget(Conf::config.getMsgKey(), 0666); if (msgid != -1) os::msgctl(msgid, IPC_RMID, NULL); + isAsyncReq = true; startAsyncServer(); } if (Conf::config.useCache() && Conf::config.useTwoWayCache()) { @@ -384,6 +385,8 @@ int main(int argc, char **argv) startCacheServer(); } printf("Database Server Started...\n"); + logFine(Conf::logger, "Database Server Started"); + monitorServer= Conf::config.useMonitorServers(); reloop: while(!srvStop) @@ -395,15 +398,32 @@ reloop: //send signal to all the registered process..check they are alive cleanupDeadProcs(sysdb); if (srvStop) break; - //TODO::if it fails to start 5 times, exit - if (isCacheReq && cachepid !=0 && checkDead(cachepid)) - startCacheServer(); + if (monitorServer) { + if (isCacheReq && cachepid !=0 && checkDead(cachepid)) { + logFine(Conf::logger, "Cache Receiver Died pid:%d", cachepid); + startCacheServer(); + } + if (isAsyncReq && asyncpid !=0 && checkDead(asyncpid)) { + logFine(Conf::logger, "Async Server Died pid:%d", asyncpid); + int msgid = os::msgget(Conf::config.getMsgKey(), 0666); + if (msgid != -1) os::msgctl(msgid, IPC_RMID, NULL); + startAsyncServer(); + } + if (isSQLReq && sqlserverpid !=0 && checkDead(sqlserverpid)) { + logFine(Conf::logger, "Network Server Died pid:%d", sqlserverpid); + os::sleep(5); + startServiceClient(); + } + } + + } + if (logActiveProcs(sysdb) != OK) {srvStop = 0; + monitorServer= Conf::config.useMonitorServers(); + goto reloop; } - if (logActiveProcs(sysdb) != OK) {srvStop = 0; goto reloop; } if (cachepid) os::kill(cachepid, SIGTERM); if(asyncpid) os::kill(asyncpid, SIGTERM); if (sqlserverpid) os::kill(sqlserverpid, SIGTERM); - //if (recoverFlag) dumpData(); if (Conf::config.useDurability() && Conf::config.useMmap()) { //ummap the memory char *startAddr = (char *) sysdb->getMetaDataPtr(); @@ -419,16 +439,3 @@ reloop: delete session; return 0; } -void dumpData() -{ - char cmd[1024]; - //TODO::TAKE exclusive lock - sprintf(cmd, "csqldump >%s/csql.db.chkpt.1",Conf::config.getDbFile()); - int ret = system(cmd); - if (ret != 0) return; - sprintf(cmd, "rm -rf %s/csql.db.cur", Conf::config.getDbFile()); - if (ret != 0) return; - sprintf(cmd, "mv %s/csql.db.chkpt.1 %s/csql.db.chkpt", Conf::config.getDbFile()); - if (ret != 0) return; - return; -} -- 2.11.4.GIT