List:Commits« Previous MessageNext Message »
From:Vladislav Vaintroub Date:August 15 2008 8:54am
Subject:bzr commit into mysql-6.0-falcon branch (vvaintroub:2774)
View as plain text  
#At file:///C:/bzr/mysql-6.0-falcon/

 2774 Vladislav Vaintroub	2008-08-15 [merge]
      merge 6.0-falcon-team -> 6.0-falcon
modified:
  configure.in
  mysql-test/suite/falcon/r/falcon_options.result
  mysql-test/suite/falcon/r/falcon_options2.result
  mysql-test/suite/falcon/t/disabled.def
  mysql-test/suite/falcon/t/falcon_bug_22179.test
  mysql-test/suite/falcon/t/falcon_bug_22845.test
  mysql-test/suite/falcon/t/falcon_bug_23818_I.test
  mysql-test/suite/falcon/t/falcon_bug_24858.test
  mysql-test/suite/falcon/t/falcon_bug_33081.test
  mysql-test/suite/falcon/t/falcon_bug_37080.test
  mysql-test/suite/falcon/t/falcon_bugs2.test
  mysql-test/suite/falcon/t/falcon_options.test
  mysql-test/suite/falcon/t/falcon_options2.test
  storage/falcon/Database.cpp
  storage/falcon/Database.h
  storage/falcon/IO.cpp
  storage/falcon/IOx.h
  storage/falcon/MemMgr.cpp
  storage/falcon/StorageHandler.cpp
  storage/falcon/StorageHandler.h
  storage/falcon/StorageTable.cpp
  storage/falcon/StorageTable.h
  storage/falcon/Table.cpp
  storage/falcon/Table.h
  storage/falcon/Transaction.cpp
  storage/falcon/Transaction.h
  storage/falcon/TransactionManager.cpp
  storage/falcon/TransactionManager.h
  storage/falcon/ha_falcon.cpp
  storage/falcon/plug.in

=== modified file 'configure.in'
--- a/configure.in	2008-08-06 08:26:05 +0000
+++ b/configure.in	2008-08-12 22:21:35 +0000
@@ -846,6 +846,7 @@ AC_CHECK_HEADERS(fcntl.h fenv.h float.h 
  execinfo.h)
 
 AC_CHECK_HEADERS([xfs/xfs.h])
+AC_CHECK_HEADERS([valgrind/memcheck.h])
 
 #--------------------------------------------------------------------
 # Check for system libraries. Adds the library to $LIBS

=== modified file 'mysql-test/suite/falcon/r/falcon_options.result'
--- a/mysql-test/suite/falcon/r/falcon_options.result	2008-07-17 13:52:17 +0000
+++ b/mysql-test/suite/falcon/r/falcon_options.result	2008-08-14 11:24:18 +0000
@@ -1,4 +1,4 @@
-SHOW VARIABLES LIKE 'falcon_%';
+SHOW VARIABLES where variable_name LIKE 'falcon_%' and variable_name <>'falcon_serial_log_dir';
 Variable_name	Value
 falcon_checkpoint_schedule	7 * * * * *
 falcon_checksums	ON
@@ -21,7 +21,6 @@ falcon_record_scavenge_threshold	67
 falcon_scavenge_schedule	15,45 * * * * *
 falcon_serial_log_block_size	0
 falcon_serial_log_buffers	20
-falcon_serial_log_dir	
 falcon_serial_log_file_size	10485760
 falcon_serial_log_priority	1
 falcon_support_xa	OFF
@@ -33,9 +32,6 @@ SELECT @@GLOBAL.falcon_debug_server;
 0
 SET GLOBAL falcon_debug_server = TRUE;
 ERROR HY000: Variable 'falcon_debug_server' is a read only variable
-SELECT @@GLOBAL.falcon_serial_log_dir;
-@@GLOBAL.falcon_serial_log_dir
-NULL
 SET GLOBAL falcon_serial_log_dir = '/foo';
 ERROR HY000: Variable 'falcon_serial_log_dir' is a read only variable
 SELECT @@GLOBAL.falcon_page_cache_size;
@@ -80,7 +76,7 @@ SELECT @@GLOBAL.falcon_record_chill_thre
 @@GLOBAL.falcon_record_chill_threshold
 1073741824
 SELECT * FROM INFORMATION_SCHEMA.global_variables
-WHERE variable_name LIKE 'falcon%';
+WHERE variable_name LIKE 'falcon%' and variable_name <> 'falcon_serial_log_dir';
 VARIABLE_NAME	VARIABLE_VALUE
 FALCON_CHECKPOINT_SCHEDULE	7 * * * * *
 FALCON_CHECKSUMS	ON
@@ -103,7 +99,6 @@ FALCON_RECORD_SCAVENGE_THRESHOLD	67
 FALCON_SCAVENGE_SCHEDULE	15,45 * * * * *
 FALCON_SERIAL_LOG_BLOCK_SIZE	0
 FALCON_SERIAL_LOG_BUFFERS	20
-FALCON_SERIAL_LOG_DIR	
 FALCON_SERIAL_LOG_FILE_SIZE	10485760
 FALCON_SERIAL_LOG_PRIORITY	1
 FALCON_SUPPORT_XA	OFF

=== modified file 'mysql-test/suite/falcon/r/falcon_options2.result'
--- a/mysql-test/suite/falcon/r/falcon_options2.result	2008-07-17 13:52:17 +0000
+++ b/mysql-test/suite/falcon/r/falcon_options2.result	2008-08-14 11:24:18 +0000
@@ -1,5 +1,5 @@
 SELECT * FROM INFORMATION_SCHEMA.global_variables
-WHERE variable_name LiKE 'falcon_%';
+WHERE variable_name LiKE 'falcon_%' AND variable_name <> 'falcon_serial_log_dir';
 VARIABLE_NAME	VARIABLE_VALUE
 FALCON_CHECKPOINT_SCHEDULE	7 * * * * *
 FALCON_CHECKSUMS	ON
@@ -22,7 +22,6 @@ FALCON_RECORD_SCAVENGE_THRESHOLD	67
 FALCON_SCAVENGE_SCHEDULE	15,45 * * * * *
 FALCON_SERIAL_LOG_BLOCK_SIZE	0
 FALCON_SERIAL_LOG_BUFFERS	20
-FALCON_SERIAL_LOG_DIR	
 FALCON_SERIAL_LOG_FILE_SIZE	10485760
 FALCON_SERIAL_LOG_PRIORITY	1
 FALCON_SUPPORT_XA	OFF
@@ -89,9 +88,6 @@ SELECT @@falcon_serial_log_block_size;
 SELECT @@falcon_serial_log_buffers;
 @@falcon_serial_log_buffers
 20
-SELECT @@falcon_serial_log_dir;
-@@falcon_serial_log_dir
-NULL
 SELECT @@falcon_serial_log_priority;
 @@falcon_serial_log_priority
 1

=== modified file 'mysql-test/suite/falcon/t/disabled.def'
--- a/mysql-test/suite/falcon/t/disabled.def	2008-08-07 21:11:55 +0000
+++ b/mysql-test/suite/falcon/t/disabled.def	2008-08-11 13:22:53 +0000
@@ -12,4 +12,3 @@
 
 falcon_bug_28095_I  : Bug#xxxxx 2008-04-22 hakank Disabled until soft restart is in main tree
 falcon_bug_28095_II : Bug#xxxxx 2008-03-22 hakank Disabled until soft restart is in main tree
-falcon_bug_22165 : Bug#22165 2008-08-07 wlad Disabled temporarily, because it crashes. Work in progress

=== modified file 'mysql-test/suite/falcon/t/falcon_bug_22179.test'
--- a/mysql-test/suite/falcon/t/falcon_bug_22179.test	2007-09-29 04:30:42 +0000
+++ b/mysql-test/suite/falcon/t/falcon_bug_22179.test	2008-08-12 08:46:11 +0000
@@ -1,4 +1,5 @@
 --source include/have_falcon.inc
+--source include/have_ucs2.inc
 #
 # Bug #22179: UCS2 searches fail if index exists	
 #

=== modified file 'mysql-test/suite/falcon/t/falcon_bug_22845.test'
--- a/mysql-test/suite/falcon/t/falcon_bug_22845.test	2008-01-31 00:07:54 +0000
+++ b/mysql-test/suite/falcon/t/falcon_bug_22845.test	2008-08-12 08:46:11 +0000
@@ -1,4 +1,5 @@
 --source include/have_falcon.inc
+--source include/have_partition.inc
 #
 # Bug #22845: Falcon: hang on partition drop
 #

=== modified file 'mysql-test/suite/falcon/t/falcon_bug_23818_I.test'
--- a/mysql-test/suite/falcon/t/falcon_bug_23818_I.test	2007-09-29 04:30:42 +0000
+++ b/mysql-test/suite/falcon/t/falcon_bug_23818_I.test	2008-08-12 08:46:11 +0000
@@ -1,4 +1,5 @@
 --source include/have_falcon.inc
+--source include/have_ucs2.inc
 SET @@storage_engine = Falcon;
 #
 # Bug #23818 Falcon: crash with random updates of long varchar columns

=== modified file 'mysql-test/suite/falcon/t/falcon_bug_24858.test'
--- a/mysql-test/suite/falcon/t/falcon_bug_24858.test	2007-09-29 04:30:42 +0000
+++ b/mysql-test/suite/falcon/t/falcon_bug_24858.test	2008-08-12 08:46:11 +0000
@@ -1,4 +1,5 @@
 --source include/have_falcon.inc
+--source include/have_ucs2.inc
 SET storage_engine = Falcon;
 #
 # Bug #24858: Falcon: searches fail if partial index on utf8 column

=== modified file 'mysql-test/suite/falcon/t/falcon_bug_33081.test'
--- a/mysql-test/suite/falcon/t/falcon_bug_33081.test	2007-12-10 10:58:37 +0000
+++ b/mysql-test/suite/falcon/t/falcon_bug_33081.test	2008-08-12 08:46:11 +0000
@@ -1,4 +1,5 @@
 --source include/have_falcon.inc
+--source include/have_ucs2.inc
 #
 # Bug #33081: Falcon: crash and database corruption when altering indexed ucs2 column
 #

=== modified file 'mysql-test/suite/falcon/t/falcon_bug_37080.test'
--- a/mysql-test/suite/falcon/t/falcon_bug_37080.test	2008-08-04 15:53:52 +0000
+++ b/mysql-test/suite/falcon/t/falcon_bug_37080.test	2008-08-14 12:08:37 +0000
@@ -1,50 +1,50 @@
---source include/have_falcon.inc
-
-#
-# Bug#37080: Falcon deadlock on parallel TRUNCATE  and INSERT
-#
---echo *** Bug #37080 ***
-
-# ----------------------------------------------------- #
-# --- Initialisation                                --- #
-# ----------------------------------------------------- #
-let $engine = 'Falcon';
-eval SET @@storage_engine = $engine;
-
---disable_warnings
-DROP TABLE IF EXISTS t1;
---enable_warnings
-
-CREATE TABLE t1(a int);
-connect (conn1,localhost,root,,);
-
-# ----------------------------------------------------- #
-# --- Test                                          --- #
-# ----------------------------------------------------- #
-
-let $num=10000;
---disable_query_log
-while ($num)
-{
-   connection conn1;
-   --send insert into t1 values(1), (3), (5), (7) , (11);
-   connection default;
-   --send truncate table t1;
-   connection conn1;
-   --error 0,ER_CANT_LOCK
-   --reap
-   connection default;
-   --error 0,ER_CANT_LOCK
-   --reap 
-   dec $num;
-}
---enable_query_log
-
-# ----------------------------------------------------- #
-# --- Check                                         --- #
-# ----------------------------------------------------- #
-
-# ----------------------------------------------------- #
-# --- Final cleanup                                 --- #
-# ----------------------------------------------------- #
-DROP TABLE t1;
+--source include/have_falcon.inc
+
+#
+# Bug#37080: Falcon deadlock on parallel TRUNCATE  and INSERT
+#
+--echo *** Bug #37080 ***
+
+# ----------------------------------------------------- #
+# --- Initialisation                                --- #
+# ----------------------------------------------------- #
+let $engine = 'Falcon';
+eval SET @@storage_engine = $engine;
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1(a int);
+connect (conn1,localhost,root,,);
+
+# ----------------------------------------------------- #
+# --- Test                                          --- #
+# ----------------------------------------------------- #
+
+let $num=1000;
+--disable_query_log
+while ($num)
+{
+   connection conn1;
+   --send insert into t1 values(1), (3), (5), (7) , (11);
+   connection default;
+   --send truncate table t1;
+   connection conn1;
+   --error 0,ER_CANT_LOCK
+   --reap
+   connection default;
+   --error 0,ER_CANT_LOCK
+   --reap 
+   dec $num;
+}
+--enable_query_log
+
+# ----------------------------------------------------- #
+# --- Check                                         --- #
+# ----------------------------------------------------- #
+
+# ----------------------------------------------------- #
+# --- Final cleanup                                 --- #
+# ----------------------------------------------------- #
+DROP TABLE t1;

=== modified file 'mysql-test/suite/falcon/t/falcon_bugs2.test'
--- a/mysql-test/suite/falcon/t/falcon_bugs2.test	2007-10-05 12:21:31 +0000
+++ b/mysql-test/suite/falcon/t/falcon_bugs2.test	2008-08-12 08:46:11 +0000
@@ -4,6 +4,7 @@ DROP TABLE IF EXISTS t2;
 --enable_warnings
 
 --source include/have_falcon.inc
+--source include/have_ucs2.inc
 SET storage_engine=falcon;
 
 # Verify that setting storage engine worked

=== modified file 'mysql-test/suite/falcon/t/falcon_options.test'
--- a/mysql-test/suite/falcon/t/falcon_options.test	2008-07-03 11:24:12 +0000
+++ b/mysql-test/suite/falcon/t/falcon_options.test	2008-08-14 11:24:18 +0000
@@ -1,8 +1,6 @@
 --source include/have_falcon.inc
 
-SHOW VARIABLES LIKE 'falcon_%';
-
---real_sleep 1
+SHOW VARIABLES where variable_name LIKE 'falcon_%' and variable_name <>'falcon_serial_log_dir';
 
 # Test that these server variables are READ ONLY.
 
@@ -10,7 +8,6 @@ SELECT @@GLOBAL.falcon_debug_server;
 --error ER_INCORRECT_GLOBAL_LOCAL_VAR
 SET GLOBAL falcon_debug_server = TRUE;
 
-SELECT @@GLOBAL.falcon_serial_log_dir;
 --error ER_INCORRECT_GLOBAL_LOCAL_VAR
 SET GLOBAL falcon_serial_log_dir = '/foo';
 
@@ -49,7 +46,7 @@ SELECT @@GLOBAL.falcon_record_chill_thre
 # Test INFORMATION_SCHEMA access to variables.
 --sorted_result
 SELECT * FROM INFORMATION_SCHEMA.global_variables
-  WHERE variable_name LIKE 'falcon%';
+  WHERE variable_name LIKE 'falcon%' and variable_name <> 'falcon_serial_log_dir';
 
 # Final cleanup.
 SET GLOBAL falcon_debug_mask = @previous_falcon_debug_mask;

=== modified file 'mysql-test/suite/falcon/t/falcon_options2.test'
--- a/mysql-test/suite/falcon/t/falcon_options2.test	2008-07-17 13:52:17 +0000
+++ b/mysql-test/suite/falcon/t/falcon_options2.test	2008-08-14 11:24:18 +0000
@@ -4,7 +4,7 @@
 
 --sorted_result
 SELECT * FROM INFORMATION_SCHEMA.global_variables
-         WHERE variable_name LiKE 'falcon_%';
+         WHERE variable_name LiKE 'falcon_%' AND variable_name <> 'falcon_serial_log_dir';
 
 SELECT @@falcon_checkpoint_schedule;
 SELECT @@falcon_consistent_read;
@@ -26,7 +26,6 @@ SELECT @@falcon_record_scavenge_threshol
 SELECT @@falcon_scavenge_schedule;
 SELECT @@falcon_serial_log_block_size;
 SELECT @@falcon_serial_log_buffers;
-SELECT @@falcon_serial_log_dir;
 SELECT @@falcon_serial_log_priority;
 SELECT @@falcon_use_deferred_index_hash;
 SELECT @@falcon_use_sectorcache;

=== modified file 'storage/falcon/Database.cpp'
--- a/storage/falcon/Database.cpp	2008-07-17 13:52:17 +0000
+++ b/storage/falcon/Database.cpp	2008-08-11 13:22:53 +0000
@@ -2282,6 +2282,11 @@ bool Database::hasUncommittedRecords(Tab
 	return transactionManager->hasUncommittedRecords(table, transaction);
 }
 
+void Database::waitForWriteComplete(Table *table)
+{
+	transactionManager->waitForWriteComplete(table);
+}
+
 void Database::commitByXid(int xidLength, const UCHAR* xid)
 {
 	serialLog->commitByXid(xidLength, xid);

=== modified file 'storage/falcon/Database.h'
--- a/storage/falcon/Database.h	2008-05-09 19:58:50 +0000
+++ b/storage/falcon/Database.h	2008-08-11 13:22:53 +0000
@@ -200,6 +200,7 @@ public:
 	virtual void	createDatabase (const char *filename);
 	void			renameTable(Table* table, const char* newSchema, const char* newName);
 	bool			hasUncommittedRecords(Table* table, Transaction *transaction);
+	void			waitForWriteComplete(Table *table);
 	void			validateCache(void);
 	int				recoverGetNextLimbo(int xidSize, unsigned char *xid);
 	void			commitByXid(int xidLength, const UCHAR* xid);

=== modified file 'storage/falcon/IO.cpp'
--- a/storage/falcon/IO.cpp	2008-07-24 08:45:03 +0000
+++ b/storage/falcon/IO.cpp	2008-08-14 16:34:43 +0000
@@ -113,6 +113,7 @@ static int simulateDiskFull = SIMULATE_D
 #endif
 	
 static FILE	*traceFile;
+static char baseDir[PATH_MAX+1]={0};
 
 #ifdef _DEBUG
 #undef THIS_FILE
@@ -142,9 +143,42 @@ IO::~IO()
 	closeFile();
 }
 
+static bool isAbsolutePath(const char *name)
+{
+#ifdef _WIN32
+	size_t len = strlen(name);
+	if(len < 2)
+		return false;
+	return (name[0]=='\\' || name[1]==':');
+#else
+	return (name[0]=='/');
+#endif
+}
+
+void IO::setBaseDirectory(const char *directory)
+{
+
+	strncpy(baseDir, directory, PATH_MAX);
+	size_t len = strlen(baseDir);
+	// Append path separator
+	if (baseDir[len-1] != SEPARATOR)
+	{
+		baseDir[len] = SEPARATOR;
+		baseDir[len+1] = 0;
+	}
+
+}
+
+static JString getPath(const char *filename)
+{
+	if(baseDir[0] == 0 || isAbsolutePath(filename))
+		return JString(filename);
+	return JString(baseDir) + filename;
+}
+
 bool IO::openFile(const char * name, bool readOnly)
 {
-	fileName = name;
+	fileName = getPath(name);
 	
 	for (int attempt = 0; attempt < 3; ++attempt)
 		{
@@ -189,7 +223,7 @@ bool IO::createFile(const char *name)
 {
 	Log::debug("IO::createFile: creating file \"%s\"\n", name);
 
-	fileName = name;
+	fileName = getPath(name);
 	
 	for (int attempt = 0; attempt < 3; ++attempt)
 		{
@@ -380,10 +414,11 @@ void IO::declareFatalError()
 void IO::createPath(const char *fileName)
 {
 	// First, better make sure directories exists
+	JString fname = getPath(fileName);
 
 	char directory [256], *q = directory;
 
-	for (const char *p = fileName; *p;)
+	for (const char *p = fname.getString(); *p;)
 		{
 		char c = *p++;
 		
@@ -393,7 +428,8 @@ void IO::createPath(const char *fileName
 			
 			if (q > directory && q [-1] != ':')
 				if (MKDIR (directory) && errno != EEXIST)
-					throw SQLError (IO_ERROR, "can't create directory \"%s\"\n", directory);
+					throw SQLError (IO_ERROR, 
+					"can't create directory \"%s\"\n", directory);
 			}
 		*q++ = c;
 		}
@@ -409,6 +445,9 @@ void IO::expandFileName(const char *file
 {
 	char expandedName[PATH_MAX+1];
 	const char *path;
+	JString fname = getPath(fileName);
+	fileName = fname.getString();
+
 #ifdef _WIN32
 	char *base;
 	
@@ -465,7 +504,8 @@ bool IO::doesFileExist(const char *fileN
 int IO::fileStat(const char *fileName, struct stat *fileStats, int *errnum)
 {
 	struct stat stats;
-	int retCode = stat(fileName, &stats);
+	JString path = getPath(fileName);
+	int retCode = stat(path.getString(), &stats);
 	
 	if (fileStats)
 		*fileStats = stats;
@@ -621,7 +661,8 @@ void IO::sync(void)
 
 void IO::deleteFile(const char* fileName)
 {
-	unlink(fileName);
+	JString path = getPath(fileName);
+	unlink(path.getString());
 }
 
 void IO::tracePage(Bdb* bdb)
@@ -753,4 +794,3 @@ uint16 IO::computeChecksum(Page *page, s
 	return (uint16) sum;
 
 }
-

=== modified file 'storage/falcon/IOx.h'
--- a/storage/falcon/IOx.h	2008-07-18 08:15:54 +0000
+++ b/storage/falcon/IOx.h	2008-08-14 11:24:18 +0000
@@ -64,6 +64,7 @@ public:
 	void	writePages(int32 pageNumber, int length, const UCHAR* data, int type);
 	void	readPage (Bdb *page);
 	bool	createFile (const char *name);
+	static	void setBaseDirectory(const char *path);
 	bool	openFile (const char *name, bool readOnly);
 	void	longSeek(int64 offset);
 	void	read(int64 offset, int length, UCHAR* buffer);

=== modified file 'storage/falcon/MemMgr.cpp'
--- a/storage/falcon/MemMgr.cpp	2008-08-11 19:56:57 +0000
+++ b/storage/falcon/MemMgr.cpp	2008-08-12 22:21:35 +0000
@@ -37,7 +37,12 @@
 #include "MemControl.h"
 
 #ifdef HAVE_purify
+#ifdef HAVE_CONFIG
+#include <config.h> 
+#endif
+#ifdef HAVE_VALGRIND_MEMCHECK_H
 #include <valgrind/memcheck.h>
+#endif
 #endif
 
 #ifndef VALGRIND_MAKE_MEM_UNDEFINED

=== modified file 'storage/falcon/StorageHandler.cpp'
--- a/storage/falcon/StorageHandler.cpp	2008-08-07 21:11:55 +0000
+++ b/storage/falcon/StorageHandler.cpp	2008-08-14 11:24:18 +0000
@@ -37,6 +37,7 @@
 #include "Dbb.h"
 #include "Database.h"
 #include "TableSpaceManager.h"
+#include "IOx.h"
 
 #define DICTIONARY_ACCOUNT		"mysql"
 #define DICTIONARY_PW			"mysql"
@@ -112,6 +113,10 @@ StorageHandler*	getFalconStorageHandler(
 	return storageHandler;
 }
 
+void StorageHandler::setDataDirectory(const char *directory)
+{
+	IO::setBaseDirectory(directory);
+}
 
 StorageHandler::StorageHandler(int lockSize)
 {

=== modified file 'storage/falcon/StorageHandler.h'
--- a/storage/falcon/StorageHandler.h	2008-07-29 10:45:39 +0000
+++ b/storage/falcon/StorageHandler.h	2008-08-14 11:24:18 +0000
@@ -141,6 +141,7 @@ public:
 	Connection			*dictionaryConnection;
 	int					mySqlLockSize;
 	bool				initialized;
+	static void			setDataDirectory(const char *directory);
 };
 
 #endif

=== modified file 'storage/falcon/StorageTable.cpp'
--- a/storage/falcon/StorageTable.cpp	2008-08-04 15:53:52 +0000
+++ b/storage/falcon/StorageTable.cpp	2008-08-11 13:22:53 +0000
@@ -565,6 +565,11 @@ int StorageTable::alterCheck(void)
 	return 0;
 }
 
+void StorageTable::waitForWriteComplete(void)
+{
+	share->table->waitForWriteComplete();
+}
+
 void StorageTable::unlockRow(void)
 {
 	if (recordLocked)

=== modified file 'storage/falcon/StorageTable.h'
--- a/storage/falcon/StorageTable.h	2008-08-04 15:53:52 +0000
+++ b/storage/falcon/StorageTable.h	2008-08-11 13:22:53 +0000
@@ -61,6 +61,7 @@ public:
 	void			transactionEnded(void);
 	void			setRecord(Record* record, bool locked);
 	int				alterCheck(void);
+	void			waitForWriteComplete();
 	void			clearAlter(void);
 	bool			setAlter(void);
 	

=== modified file 'storage/falcon/Table.cpp'
--- a/storage/falcon/Table.cpp	2008-08-07 21:11:55 +0000
+++ b/storage/falcon/Table.cpp	2008-08-13 10:18:40 +0000
@@ -3331,6 +3331,11 @@ bool Table::hasUncommittedRecords(Transa
 	return database->hasUncommittedRecords(this, transaction);
 }
 
+void Table::waitForWriteComplete()
+{
+	database->waitForWriteComplete(this);
+}
+
 RecordVersion* Table::lockRecord(Record* record, Transaction* transaction)
 {
 	Record *current = fetch(record->recordNumber);

=== modified file 'storage/falcon/Table.h'
--- a/storage/falcon/Table.h	2008-04-22 21:10:23 +0000
+++ b/storage/falcon/Table.h	2008-08-11 13:22:53 +0000
@@ -185,6 +185,7 @@ public:
 	int			getFormatVersion();
 	void		validateAndInsert(Transaction *transaction, RecordVersion *record);
 	bool		hasUncommittedRecords(Transaction* transaction);
+	void		waitForWriteComplete();
 	void		checkAncestor(Record* current, Record* oldRecord);
 	int64		estimateCardinality(void);
 	void		optimize(Connection *connection);

=== modified file 'storage/falcon/Transaction.cpp'
--- a/storage/falcon/Transaction.cpp	2008-07-31 10:04:30 +0000
+++ b/storage/falcon/Transaction.cpp	2008-08-14 11:18:42 +0000
@@ -275,38 +275,43 @@ void Transaction::commit()
 		releaseRecordLocks();
 
 	database->serialLog->preCommit(this);
-	state = Committed;
 	syncActive.unlock();
 
+	
+
 	for (RecordVersion *record = firstRecord; record; record = record->nextInTrans)
-		if (!record->isSuperceded() && record->state != recLock)
-			record->format->table->updateRecord (record);
+	{
+		Table * table = record->format->table;
 
-	if (commitTriggers)
-		for (RecordVersion *record = firstRecord; record; record = record->nextInTrans)
-			if (!record->isSuperceded() && record->state != recLock)
-				record->format->table->postCommit (this, record);
+		if (!record->isSuperceded() && record->state != recLock)
+			{
+			table->updateRecord (record);
+			if (commitTriggers)
+				table->postCommit (this, record);
+			}
 
+		if (!record->getPriorVersion())
+			++table->cardinality;
+		if (record->state == recDeleted && table->cardinality > 0)
+			--table->cardinality;
+	}
+	
 	releaseDependencies();
 	database->flushInversion(this);
 
+	// Transfer transaction from active list to committed list, set committed state
 	Sync syncCommitted(&transactionManager->committedTransactions.syncObject, "Transaction::commit(2)");
-	syncCommitted.lock(Exclusive);
-
 	Sync syncActiveTransactions(&transactionManager->activeTransactions.syncObject, "Transaction::commit(3)");
+	syncCommitted.lock(Exclusive);
 	syncActiveTransactions.lock(Exclusive);
+
 	transactionManager->activeTransactions.remove(this);
-	syncActiveTransactions.unlock();
-	
-	for (RecordVersion *record = firstRecord; record; record = record->nextInTrans)
-		{
-		if (!record->getPriorVersion())
-			++record->format->table->cardinality;
-		if (record->state == recDeleted && record->format->table->cardinality > 0)
-			--record->format->table->cardinality;
-		}
 	transactionManager->committedTransactions.append(this);
+	state = Committed;
+
+	syncActiveTransactions.unlock();
 	syncCommitted.unlock();
+
 	database->commit(this);
 
 	delete [] xid;
@@ -778,7 +783,8 @@ void Transaction::releaseDependencies()
 
 			if (COMPARE_EXCHANGE_POINTER(&state->transaction, transaction, NULL))
 				{
-				ASSERT(transaction->transactionId == state->transactionId || transaction->state == Available);
+				ASSERT(transaction->transactionId == state->transactionId || transaction->transactionId == 0);
+				ASSERT(transaction->state != Initializing);
 				transaction->releaseDependency();
 				}
 			}
@@ -925,8 +931,11 @@ void Transaction::truncateTable(Table* t
 			ptr = &rec->nextInTrans;
 }
 
-bool Transaction::hasUncommittedRecords(Table* table)
+bool Transaction::hasRecords(Table* table)
 {
+	// This lock is to avoid race with writeComplete
+	Sync sync(&syncIndexes, "Transaction::hasRecords");
+	sync.lock(Exclusive);
 	for (RecordVersion *rec = firstRecord; rec; rec = rec->nextInTrans)
 		if (rec->format->table == table)
 			return true;

=== modified file 'storage/falcon/Transaction.h'
--- a/storage/falcon/Transaction.h	2008-07-24 08:45:03 +0000
+++ b/storage/falcon/Transaction.h	2008-08-11 13:22:53 +0000
@@ -105,7 +105,7 @@ public:
 	State		waitForTransaction (Transaction *transaction, TransId transId, bool *deadlock);
 	void		dropTable(Table* table);
 	void		truncateTable(Table* table);
-	bool		hasUncommittedRecords(Table* table);
+	bool		hasRecords(Table* table);
 	void		writeComplete(void);
 	void		releaseDependency(void);
 	int			createSavepoint();

=== modified file 'storage/falcon/TransactionManager.cpp'
--- a/storage/falcon/TransactionManager.cpp	2008-07-24 08:45:03 +0000
+++ b/storage/falcon/TransactionManager.cpp	2008-08-14 12:08:37 +0000
@@ -27,6 +27,7 @@
 #include "Log.h"
 #include "LogLock.h"
 #include "Synchronize.h"
+#include "Thread.h"
 
 static const int EXTRA_TRANSACTIONS = 10;
 
@@ -168,12 +169,40 @@ bool TransactionManager::hasUncommittedR
 	syncTrans.lock (Shared);
 	
 	for (Transaction *trans = activeTransactions.first; trans; trans = trans->next)
-		if (trans != transaction && trans->isActive() && trans->hasUncommittedRecords(table))
+		if (trans != transaction && trans->isActive() && trans->hasRecords(table))
 			return true;
 
 	return false;
 }
 
+// Wait until all committed records for a table are purged by gophers
+// (their transaction become write complete)
+void TransactionManager::waitForWriteComplete(Table* table)
+{
+	for(;;)
+		{
+		bool again = false;
+		Sync committedTrans (&committedTransactions.syncObject,
+			"TransactionManager::waitForWriteComplete");
+		committedTrans.lock (Shared);
+
+		for (Transaction *trans = committedTransactions.first; trans; 
+			 trans = trans->next)
+			{
+				if (trans->hasRecords(table)&& trans->writePending)
+				{
+				again = true;
+				break;
+				}
+			}
+
+		if(!again)
+			return;
+
+		committedTrans.unlock();
+		Thread::getThread("TransactionManager::waitForWriteComplete")->sleep(10);
+		}
+}
 void TransactionManager::commitByXid(int xidLength, const UCHAR* xid)
 {
 	Sync sync (&activeTransactions.syncObject, "TransactionManager::commitByXid");

=== modified file 'storage/falcon/TransactionManager.h'
--- a/storage/falcon/TransactionManager.h	2008-04-24 17:26:34 +0000
+++ b/storage/falcon/TransactionManager.h	2008-08-11 13:22:53 +0000
@@ -35,6 +35,7 @@ public:
 	void			dropTable(Table* table, Transaction* transaction);
 	void			truncateTable(Table* table, Transaction* transaction);
 	bool			hasUncommittedRecords(Table* table, Transaction* transaction);
+	void			waitForWriteComplete(Table *table);
 	void			commitByXid(int xidLength, const UCHAR* xid);
 	void			rollbackByXid(int xidLength, const UCHAR* xid);
 	void			print(void);

=== modified file 'storage/falcon/ha_falcon.cpp'
--- a/storage/falcon/ha_falcon.cpp	2008-08-11 16:17:26 +0000
+++ b/storage/falcon/ha_falcon.cpp	2008-08-14 11:24:18 +0000
@@ -162,9 +162,11 @@ int StorageInterface::falcon_init(void *
 	falcon_hton = (handlerton *)p;
 	my_bool error = false;
 
+	StorageHandler::setDataDirectory(mysql_real_data_home);
+
 	if (!storageHandler)
 		storageHandler = getFalconStorageHandler(sizeof(THR_LOCK));
-
+	
 	falcon_hton->state = SHOW_OPTION_YES;
 	falcon_hton->db_type = DB_TYPE_FALCON;
 	falcon_hton->savepoint_offset = sizeof(void*);
@@ -177,6 +179,8 @@ int StorageInterface::falcon_init(void *
 	falcon_hton->create = falcon_create_handler;
 	falcon_hton->drop_database  = StorageInterface::dropDatabase;
 	falcon_hton->panic  = StorageInterface::panic;
+
+
 #if 0
 	falcon_hton->alter_table_flags  = StorageInterface::alter_table_flags;
 #endif
@@ -1893,6 +1897,7 @@ int StorageInterface::external_lock(THD 
 					DBUG_RETURN(error(ret));
 					}
 				}
+				storageTable->waitForWriteComplete();
 				break;
 			default:
 				break;
@@ -3524,7 +3529,7 @@ void StorageInterface::unmapFields(void)
 static MYSQL_SYSVAR_STR(serial_log_dir, falcon_serial_log_dir,
   PLUGIN_VAR_RQCMDARG| PLUGIN_VAR_READONLY | PLUGIN_VAR_MEMALLOC,
   "Falcon serial log file directory.",
-  NULL, NULL, NULL);
+  NULL, NULL, mysql_real_data_home);
 
 static MYSQL_SYSVAR_STR(checkpoint_schedule, falcon_checkpoint_schedule,
   PLUGIN_VAR_RQCMDARG| PLUGIN_VAR_READONLY | PLUGIN_VAR_MEMALLOC,

=== modified file 'storage/falcon/plug.in'
--- a/storage/falcon/plug.in	2008-07-25 12:31:16 +0000
+++ b/storage/falcon/plug.in	2008-08-12 21:50:50 +0000
@@ -9,6 +9,7 @@ AC_CACHE_CHECK([if Falcon Storage Engine
   			   falcon_supported_by_machine,[
   case "$BASE_MACHINE_TYPE" in
     i386)   falcon_supported_by_machine="yes" ;;
+    amd64)  falcon_supported_by_machine="yes" ;;
     x86_64) falcon_supported_by_machine="yes" ;;
     powerpc)falcon_supported_by_machine="yes" ;;
     sparc)

Thread
bzr commit into mysql-6.0-falcon branch (vvaintroub:2774) Vladislav Vaintroub15 Aug