MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Kevin Lewis Date:June 25 2008 4:59pm
Subject:RE: bzr commit into mysql-6.0-falcon branch (vvaintroub:2715) WL#4172
View as plain text  
Vlad,

I looked again at this code and agree with the changes you made.  But this
time, I noticed that the Windows implementation of truncate() will try to
reset the current file pointer to where it was before the truncation, even
if it is greater than falcon_serial_log_file_size.  

I could not find what would happen if SetFilePointerEx() is set to an offset
passed the end of the file.  Do you know?  Will it return an error?

Kevin

>-----Original Message-----
>From: Vladislav Vaintroub [mailto:vvaintroub@stripped]
>Sent: Monday, June 23, 2008 5:23 AM
>To: commits@stripped
>Subject: bzr commit into mysql-6.0-falcon branch (vvaintroub:2715) WL#4172
>
>#At bzr+ssh://bk-internal.mysql.com/bzrroot/server/mysql-6.0-falcon/
>
> 2715 Vladislav Vaintroub	2008-06-23
>      WL#4172 : Truncate Falcon Log Files
>      Introduce a new parameter falcon_serial_log_file_size for maximum
size
>of
>      a serial log file before it gets truncated. During the log switch,
>check the
>      file size. Truncate, if file is too big.
>modified:
>  mysql-test/suite/falcon/r/falcon_options.result
>  mysql-test/suite/falcon/r/falcon_options2.result
>  storage/falcon/SerialLog.cpp
>  storage/falcon/SerialLogFile.cpp
>  storage/falcon/SerialLogFile.h
>  storage/falcon/ha_falcon.cpp
>
>per-file messages:
>  mysql-test/suite/falcon/r/falcon_options.result
>    New parameter falcon_serial_log_file_size
>  mysql-test/suite/falcon/r/falcon_options2.result
>    New parameter falcon_serial_log_file_size
>  storage/falcon/SerialLog.cpp
>    During the log switch, check the  file size. Truncate, if file is too
>big.
>  storage/falcon/SerialLogFile.cpp
>    New functions truncate() and size()
>  storage/falcon/SerialLogFile.h
>    New functions truncate() and size()
>  storage/falcon/ha_falcon.cpp
>    New parameter falcon_serial_log_file_size
>=== modified file 'mysql-test/suite/falcon/r/falcon_options.result'
>--- a/mysql-test/suite/falcon/r/falcon_options.result	2008-03-11
>16:15:47 +0000
>+++ b/mysql-test/suite/falcon/r/falcon_options.result	2008-06-23
>10:22:43 +0000
>@@ -23,6 +23,7 @@ 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
> falcon_use_deferred_index_hash	OFF
>@@ -111,6 +112,7 @@ 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
> FALCON_USE_DEFERRED_INDEX_HASH	OFF
>
>=== modified file 'mysql-test/suite/falcon/r/falcon_options2.result'
>--- a/mysql-test/suite/falcon/r/falcon_options2.result	2008-03-11
>16:15:47 +0000
>+++ b/mysql-test/suite/falcon/r/falcon_options2.result	2008-06-23
>10:22:43 +0000
>@@ -24,6 +24,7 @@ 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
> FALCON_USE_DEFERRED_INDEX_HASH	OFF
>
>=== modified file 'storage/falcon/SerialLog.cpp'
>--- a/storage/falcon/SerialLog.cpp	2008-04-12 02:22:50 +0000
>+++ b/storage/falcon/SerialLog.cpp	2008-06-23 10:22:43 +0000
>@@ -53,6 +53,7 @@ static const char THIS_FILE[]=__FILE__;
> static const int TRACE_PAGE = 0;
>
> extern uint falcon_gopher_threads;
>+extern uint64 falcon_serial_log_file_size;
>
> //static const int windowBuffers = 10;
> static bool debug;
>@@ -597,8 +598,19 @@ void SerialLog::createNewWindow(void)
> 			break;
> 			}
>
>-	if (fileOffset == 0 && Log::isActive(LogInfo))
>-		Log::log(LogInfo, "%d: Switching log files (%d used)\n",
>database->deltaTime, file->highWater);
>+	if (fileOffset == 0)
>+		{
>+		// Logfile switch, truncate file if required
>+
>+		if (Log::isActive(LogInfo))
>+			Log::log(LogInfo, "%d: Switching log files (%d
used)\n",
>+					database->deltaTime,
file->highWater);
>+
>+		if((uint64)file->size() > falcon_serial_log_file_size)
>+			file->truncate((int64)falcon_serial_log_file_size);
>+		}
>+
>+
>
> 	writeWindow->deactivateWindow();
> 	writeWindow = allocWindow(file, fileOffset);
>
>=== modified file 'storage/falcon/SerialLogFile.cpp'
>--- a/storage/falcon/SerialLogFile.cpp	2008-05-09 20:14:24 +0000
>+++ b/storage/falcon/SerialLogFile.cpp	2008-06-23 10:22:43 +0000
>@@ -305,6 +305,57 @@ uint32 SerialLogFile::read(int64 positio
> #endif
> }
>
>+void SerialLogFile::truncate(int64 size)
>+{
>+#ifdef _WIN32
>+	LARGE_INTEGER oldPos, distance;
>+	distance.QuadPart = 0;
>+
>+	// Get current position in file
>+	if (!SetFilePointerEx(handle, distance ,&oldPos,FILE_CURRENT))
>+		throw SQLError(IO_ERROR, "SetFilePointerEx failed with %d",
>+						GetLastError());
>+
>+	// Position to the new end of file , set EOF marker there
>+	distance.QuadPart = size;
>+	if (!SetFilePointerEx(handle, distance, 0, FILE_BEGIN))
>+		throw SQLError(IO_ERROR, "SetFilePointerEx failed with %d",
>+						GetLastError());
>+
>+	if (!SetEndOfFile(handle))
>+		throw SQLError(IO_ERROR, "SetEndOfFile failed with %d",
>+						GetLastError());
>+
>+
>+	// Restore file pointer
>+	if (!SetFilePointerEx(handle, oldPos ,0,FILE_BEGIN))
>+		throw SQLError(IO_ERROR, "SetFilePointerEx failed with %d",
>+						GetLastError());
>+#else
>+	if (ftruncate(handle, size))
>+		throw SQLError(IO_ERROR, "ftruncate failed with %d",
>+						errno);
>+#endif
>+}
>+
>+int64 SerialLogFile::size(void)
>+{
>+#ifdef _WIN32
>+	LARGE_INTEGER size;
>+
>+	if (!GetFileSizeEx(handle, &size))
>+		throw SQLError(IO_ERROR, "GetFileSizeEx failed with %u",
>+						GetLastError());
>+
>+	return size.QuadPart;
>+#else
>+	struct stat buf;
>+	if (fstat(handle, &buf))
>+		throw SQLError(IO_ERROR, "stat failed with %d",
>+						errno);
>+	return  buf.st_size;
>+#endif
>+}
>
> void SerialLogFile::zap()
> {
>
>=== modified file 'storage/falcon/SerialLogFile.h'
>--- a/storage/falcon/SerialLogFile.h	2008-03-11 16:15:47 +0000
>+++ b/storage/falcon/SerialLogFile.h	2008-06-23 10:22:43 +0000
>@@ -38,6 +38,8 @@ public:
> 	void write(int64 position, uint32 length, const SerialLogBlock
*data);
> 	void close();
> 	void open (JString filename, bool creat);
>+	void truncate(int64 size);
>+	int64 size(void);
> 	SerialLogFile(Database *db);
> 	virtual ~SerialLogFile();
>
>
>=== modified file 'storage/falcon/ha_falcon.cpp'
>--- a/storage/falcon/ha_falcon.cpp	2008-06-19 12:39:21 +0000
>+++ b/storage/falcon/ha_falcon.cpp	2008-06-23 10:22:43 +0000
>@@ -80,6 +80,7 @@ static StorageHandler	*storageHandler;
>
> ulonglong	falcon_record_memory_max;
> ulonglong	falcon_initial_allocation;
>+ulonglong	falcon_serial_log_file_size;
> uint		falcon_allocation_extent;
> ulonglong	falcon_page_cache_size;
> char*		falcon_serial_log_dir;
>@@ -3510,6 +3511,11 @@ static MYSQL_SYSVAR_ULONGLONG(initial_al
>   "Initial allocation (in bytes) of falcon user tablespace.",
>   NULL, NULL, 0, 0, LL(4000000000), LL(1)<<20);
>
>+static MYSQL_SYSVAR_ULONGLONG(serial_log_file_size,
>falcon_serial_log_file_size,
>+  PLUGIN_VAR_RQCMDARG,
>+  "If serial log file grows larger than this value, it will be truncated
>when it is reused",
>+  NULL, NULL , LL(10)<<20, LL(1)<<20,LL(0x7fffffffffffffff),
> LL(1)<<20);
>+
> /***
> static MYSQL_SYSVAR_UINT(allocation_extent, falcon_allocation_extent,
>   PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,
>@@ -3557,6 +3563,7 @@ static struct st_mysql_sys_var* falconVa
> 	//MYSQL_SYSVAR(allocation_extent),
> 	MYSQL_SYSVAR(page_cache_size),
> 	MYSQL_SYSVAR(consistent_read),
>+	MYSQL_SYSVAR(serial_log_file_size),
> 	NULL
> };
>
>
>
>--
>MySQL Code Commits Mailing List
>For list archives: http://lists.mysql.com/commits
>To unsubscribe:    http://lists.mysql.com/commits?unsub=1

Thread
bzr commit into mysql-6.0-falcon branch (vvaintroub:2715) WL#4172Vladislav Vaintroub23 Jun
  • Re: bzr commit into mysql-6.0-falcon branch (vvaintroub:2715) WL#4172Olav Sandstaa24 Jun
  • RE: bzr commit into mysql-6.0-falcon branch (vvaintroub:2715) WL#4172Kevin Lewis25 Jun
    • RE: bzr commit into mysql-6.0-falcon branch (vvaintroub:2715) WL#4172Vladislav Vaintroub25 Jun
      • RE: bzr commit into mysql-6.0-falcon branch (vvaintroub:2715) WL#4172Kevin Lewis25 Jun