MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:vvaintroub Date:January 31 2008 6:26pm
Subject: bk commit into 6.0 tree (vvaintroub:1.2785) BUG#34086
View as plain text  
Below is the list of changes that have just been committed into a local
6.0 repository of vvaintroub. When vvaintroub does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2008-01-31 19:25:51+01:00, vvaintroub@wva. +6 -0
  Bug#34086 :
   
  *If falcon_page_cache_size is too big, this can lead to 
  crashes.  All existing falcon data will be erased because 
  StorageConnection::initialize()  handles any exception from openDatabase()
  with an attempt to create a new database. 
  
  This has been fix with the change.
  
  *Another issue that has been fixed is dereferencing null pointers after
  failing page cache allocation.
   
  *Also, we do not try to initialize Falcon after an already failed 
  initialization.

  storage/falcon/Dbb.cpp@stripped, 2008-01-31 19:25:46+01:00, vvaintroub@wva. +15 -5
    Cleanup empty file master.fts, if database creation is not successfull,
    e.g after memory allocation error.

  storage/falcon/IO.cpp@stripped, 2008-01-31 19:25:47+01:00, vvaintroub@wva. +5 -4
    return FILE_ACCESS_ERROR instead of CONNECTION_ERROR if file  cannot be 
    opened due to either locking problems or failing permissions. 

  storage/falcon/SQLException.h@stripped, 2008-01-31 19:25:47+01:00, vvaintroub@wva. +2 -1
    New FILE_ACCESS_ERROR

  storage/falcon/StorageHandler.cpp@stripped, 2008-01-31 19:25:48+01:00, vvaintroub@wva. +16
-3
    -Avoid dereferencing null-pointer if page cache could not be allocated
    -Avoid calling StorageHandler::initialize() again after failure,  
    errors are irrepairable.
    -Do not attempt to create MASTER, if it could not be opened because of
    either memory allocation errors or file sharing or permission problems

  storage/falcon/StorageHandler.h@stripped, 2008-01-31 19:25:48+01:00, vvaintroub@wva. +1 -0
    Track whether initialize() has already been called, don't call it many 
    times after failure.

  storage/falcon/StorageTableShare.cpp@stripped, 2008-01-31 19:25:49+01:00, vvaintroub@wva. +2
-0
    Avoid dereferencing null-pointer if page cache could not be allocated.

diff -Nrup a/storage/falcon/Dbb.cpp b/storage/falcon/Dbb.cpp
--- a/storage/falcon/Dbb.cpp	2008-01-19 18:59:10 +01:00
+++ b/storage/falcon/Dbb.cpp	2008-01-31 19:25:46 +01:00
@@ -153,12 +153,22 @@ Cache* Dbb::create(const char * fileName
 	odsVersion = ODS_VERSION;
 	odsMinorVersion = ODS_MINOR_VERSION;
 	sequence = 1;
-	createFile(fileName, initialAllocation);
+
 	init (pageSz, (int) ((cacheSize + pageSz - 1) / pageSz));
-	Hdr::create (this, fileType, transId, logRoot);
-	PageInventoryPage::create (this, transId);
-	SectionRootPage::create (this, transId);
-	IndexRootPage::create (this, transId);
+	createFile(fileName, initialAllocation);
+	try
+		{
+		Hdr::create (this, fileType, transId, logRoot);
+		PageInventoryPage::create (this, transId);
+		SectionRootPage::create (this, transId);
+		IndexRootPage::create (this, transId);
+		}
+	catch(...)
+		{
+		closeFile();
+		deleteFile();
+		throw;
+		}
 
 	return cache;
 }
diff -Nrup a/storage/falcon/IO.cpp b/storage/falcon/IO.cpp
--- a/storage/falcon/IO.cpp	2007-12-26 22:51:16 +01:00
+++ b/storage/falcon/IO.cpp	2008-01-31 19:25:47 +01:00
@@ -142,8 +142,10 @@ bool IO::openFile(const char * name, boo
 		}
 
 	if (fileId < 0)
-		throw SQLEXCEPTION (CONNECTION_ERROR, "can't open file \"%s\": %s (%d)", 
-							name, strerror (errno), errno);
+		{
+			int sqlError = (errno == EACCES )? FILE_ACCESS_ERROR :CONNECTION_ERROR;
+			throw SQLEXCEPTION (sqlError, "can't open file \"%s\": %s (%d)", name, strerror
(errno), errno);
+		}
 
 	isReadOnly = readOnly;
 	
@@ -184,8 +186,7 @@ bool IO::createFile(const char *name, ui
 		}
 
 	if (fileId < 0)
-		throw SQLEXCEPTION (CONNECTION_ERROR, "can't create file \"%s\", %s (%d)", 
-								name, strerror (errno), errno);
+		throw SQLEXCEPTION (CONNECTION_ERROR,"can't create file \"%s\", %s (%d)", name,
strerror (errno), errno);
 
 	isReadOnly = false;
 #ifndef _WIN32
diff -Nrup a/storage/falcon/SQLException.h b/storage/falcon/SQLException.h
--- a/storage/falcon/SQLException.h	2007-11-28 18:20:53 +01:00
+++ b/storage/falcon/SQLException.h	2008-01-31 19:25:47 +01:00
@@ -67,7 +67,8 @@ enum SqlCode {
 	TABLESPACE_EXIST_ERROR		= -33,
 	TABLESPACE_NOT_EMPTY		= -34,
 	TABLESPACE_NOT_EXIST_ERROR	= -35,
-	DEVICE_FULL					= -36
+	DEVICE_FULL					= -36,
+	FILE_ACCESS_ERROR			= -37
 	};
 
 class DllExport SQLException {
diff -Nrup a/storage/falcon/StorageHandler.cpp b/storage/falcon/StorageHandler.cpp
--- a/storage/falcon/StorageHandler.cpp	2008-01-26 23:52:21 +01:00
+++ b/storage/falcon/StorageHandler.cpp	2008-01-31 19:25:48 +01:00
@@ -102,6 +102,7 @@ StorageHandler::StorageHandler(int lockS
 	dictionaryConnection = NULL;
 	databaseList = NULL;
 	defaultDatabase = NULL;
+	initialized = false;
 }
 
 StorageHandler::~StorageHandler(void)
@@ -642,6 +643,9 @@ StorageConnection* StorageHandler::getSt
 	if (!defaultDatabase)
 		initialize();
 
+	if (!dictionaryConnection)
+		return NULL;
+
 	if (!tableShare->storageDatabase)
 		tableShare->findDatabase();
 
@@ -887,14 +891,16 @@ void StorageHandler::getTransactionSumma
 
 void StorageHandler::initialize(void)
 {
-	if (defaultDatabase)
+
+	if (initialized)
 		return;
 	
 	Sync sync(&syncObject, "StorageConnection::initialize");
 	sync.lock(Exclusive);
 	
-	if (defaultDatabase)
+	if (initialized)
 		return;
+	initialized = true;
 		
 	defaultDatabase = getStorageDatabase(MASTER_NAME, MASTER_PATH);
 	
@@ -904,8 +910,15 @@ void StorageHandler::initialize(void)
 		dictionaryConnection = defaultDatabase->getOpenConnection();
 		dropTempTables();
 		}
-	catch (...)
+	catch (SQLException &e)
 		{
+		// No point in creating a database if we got memory error.
+		// On FILE_ACCESS_ERROR, an external application can temporarily lock the file.
+		// In this both cases, trying to create database in this case could eventually
+		// lead to "recreate" and data loss.
+		int err = e.getSqlcode();
+		if(err == OUT_OF_MEMORY_ERROR || err == FILE_ACCESS_ERROR)
+			return;
 		try
 			{
 			defaultDatabase->createDatabase();
diff -Nrup a/storage/falcon/StorageHandler.h b/storage/falcon/StorageHandler.h
--- a/storage/falcon/StorageHandler.h	2007-12-02 21:17:12 +01:00
+++ b/storage/falcon/StorageHandler.h	2008-01-31 19:25:48 +01:00
@@ -134,6 +134,7 @@ public:
 	StorageTableShare	*tables[tableHashSize];
 	Connection			*dictionaryConnection;
 	int					mySqlLockSize;
+	bool				initialized;
 	virtual void getFalconVersionInfo(InfoTable* infoTable);
 };
 
diff -Nrup a/storage/falcon/StorageTableShare.cpp b/storage/falcon/StorageTableShare.cpp
--- a/storage/falcon/StorageTableShare.cpp	2008-01-04 00:35:04 +01:00
+++ b/storage/falcon/StorageTableShare.cpp	2008-01-31 19:25:49 +01:00
@@ -358,6 +358,8 @@ void StorageTableShare::load(void)
 	Sync sync(&storageHandler->dictionarySyncObject, "StorageTableShare::load");
 	sync.lock(Exclusive);
 	Connection *connection = storageHandler->getDictionaryConnection();
+	if (!connection)
+		return;
 	PreparedStatement *statement = connection->prepareStatement(
 		"select
given_schema_name,given_table_name,effective_schema_name,effective_table_name,tablespace_name
"
 		"from falcon.tables where pathname=?");


Thread
bk commit into 6.0 tree (vvaintroub:1.2785) BUG#34086vvaintroub31 Jan