Feature req: innodb_log_file_size smarter on startup

Bug #303124 reported by Arjen Lentz
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OurDelta
Fix Committed
Wishlist
Antony T Curtis
Percona Server moved to https://jira.percona.com/projects/PS
Status tracked in 5.7
5.1
Won't Fix
Wishlist
Unassigned
5.5
Won't Fix
Wishlist
Unassigned
5.6
Fix Released
Wishlist
Unassigned
5.7
Invalid
Undecided
Unassigned
Percona patches
Won't Fix
Wishlist
Unassigned
Percona-XtraDB
Won't Fix
Wishlist
Unassigned

Bug Description

Feature request:
On InnoDB startup, check whether the iblog files exist, and what size they are.
Feed that size back into the innodb_log_file_size, regardless of what it was.
If it was different, you can write a warning to errorlog, but no error/abort.

This little tweak would allow us to increase the default log file size, without breaking existing installations.

Revision history for this message
Arjen Lentz (arjen-lentz) wrote :

OurDelta would like to see this for 5.1
Backport to 5.0 ok but not urgent.

Changed in ourdelta:
importance: Undecided → Wishlist
description: updated
Changed in percona-patches:
importance: Undecided → Wishlist
status: New → Confirmed
Changed in ourdelta:
status: New → In Progress
assignee: nobody → Antony T Curtis (atcurtis)
Revision history for this message
Arjen Lentz (arjen-lentz) wrote :

=== modified file 'storage/xtradb/handler/ha_innodb.cc'
--- storage/xtradb/handler/ha_innodb.cc 2009-09-09 21:06:57 +0000
+++ storage/xtradb/handler/ha_innodb.cc 2009-10-14 03:12:52 +0000
@@ -2405,6 +2405,9 @@
  /* Get the current high water mark format. */
  innobase_file_format_check = (char*) trx_sys_file_format_max_get();

+ /* Get the current log file size. */
+ innobase_log_file_size = srv_log_file_size;
+
  DBUG_RETURN(FALSE);
 error:
  DBUG_RETURN(TRUE);

=== modified file 'storage/xtradb/srv/srv0start.c'
--- storage/xtradb/srv/srv0start.c 2009-09-16 17:43:01 +0000
+++ storage/xtradb/srv/srv0start.c 2009-10-14 03:17:20 +0000
@@ -547,6 +547,21 @@
 }

 /*************************************************************************
+Calculates the number of database pages which are represented by the
+file size in bytes. */
+static
+ulint
+srv_calc_pages(
+/*============*/
+ /* out: file size in database pages */
+ ulint size, /* in: low 32 bits of file size in bytes */
+ ulint size_high) /* in: high 32 bits of file size in bytes */
+{
+ return((size >> UNIV_PAGE_SIZE_SHIFT)
+ | (size_high << (32 - UNIV_PAGE_SIZE_SHIFT));
+}
+
+/*************************************************************************
 Creates or opens the log files and closes them. */
 static
 ulint
@@ -611,8 +626,9 @@
   ret = os_file_get_size(files[i], &size, &size_high);
   ut_a(ret);

- if (size != srv_calc_low32(srv_log_file_size)
- || size_high != srv_calc_high32(srv_log_file_size)) {
+ if ((size != srv_calc_low32(srv_log_file_size)
+ || size_high != srv_calc_high32(srv_log_file_size))
+ && log_file_has_been_opened) {

    fprintf(stderr,
     "InnoDB: Error: log file %s is"
@@ -625,6 +641,7 @@

    return(DB_ERROR);
   }
+ srv_log_file_size = srv_calc_pages(size, size_high);
  } else {
   *log_file_created = TRUE;

Revision history for this message
Arjen Lentz (arjen-lentz) wrote :

(sorry, mistake in the feedback to the system variables, fixed patch below)

In a nutshell, this patch allows the default log file size to be changed (in the compiled-in default, or my.cnf) for new installations, without breaking existing installations.

It does the following: if the iblogfiles already exist, and size differs from innodb_log_file_size, issue a warning but not abort; it'll also update the system variable with the actual log file size.

For an existing installation, the user can simply update the my.cnf with the actual file size to get rid of the warning, or do the procedure for changing the log file size.

=== modified file 'storage/xtradb/handler/ha_innodb.cc'
--- storage/xtradb/handler/ha_innodb.cc 2009-09-09 21:06:57 +0000
+++ storage/xtradb/handler/ha_innodb.cc 2009-10-14 03:40:05 +0000
@@ -2405,6 +2405,10 @@
  /* Get the current high water mark format. */
  innobase_file_format_check = (char*) trx_sys_file_format_max_get();

+ /* Get the current log file size. */
+ innobase_log_file_size = srv_log_file_size;
+ innobase_log_file_size *= UNIV_PAGE_SIZE;
+
  DBUG_RETURN(FALSE);
 error:
  DBUG_RETURN(TRUE);

=== modified file 'storage/xtradb/srv/srv0start.c'
--- storage/xtradb/srv/srv0start.c 2009-09-16 17:43:01 +0000
+++ storage/xtradb/srv/srv0start.c 2009-10-14 03:26:54 +0000
@@ -547,6 +547,21 @@
 }

 /*************************************************************************
+Calculates the number of database pages which are represented by the
+file size in bytes. */
+static
+ulint
+srv_calc_pages(
+/*============*/
+ /* out: file size in database pages */
+ ulint size, /* in: low 32 bits of file size in bytes */
+ ulint size_high) /* in: high 32 bits of file size in bytes */
+{
+ return((size >> UNIV_PAGE_SIZE_SHIFT)
+ | (size_high << (32 - UNIV_PAGE_SIZE_SHIFT));
+}
+
+/*************************************************************************
 Creates or opens the log files and closes them. */
 static
 ulint
@@ -623,7 +638,12 @@
     (ulong) srv_calc_high32(srv_log_file_size),
     (ulong) srv_calc_low32(srv_log_file_size));

- return(DB_ERROR);
+ if (log_file_has_been_opened) {
+
+ return(DB_ERROR);
+ }
+
+ srv_log_file_size = srv_calc_pages(size, size_high);
   }
  } else {
   *log_file_created = TRUE;

Revision history for this message
Arjen Lentz (arjen-lentz) wrote :

tnx to Antony Curtis for this.

Changed in ourdelta:
status: In Progress → Fix Committed
Revision history for this message
Vadim Tkachenko (vadim-tk) wrote :

Can InnoDB actually increase log_files automatically (i.e. from default 5M to 50M ) ?
In current way it will cause a lot of confusing, you set 1000M, but system still runs on 5M

Revision history for this message
Arjen Lentz (arjen-lentz) wrote : Re: [Bug 303124] Re: Feature req: innodb_log_file_size smarter on startup

Hi Vadim

On 14/10/2009, at 2:54 PM, Vadim Tkachenko wrote:
> Can InnoDB actually increase log_files automatically (i.e. from
> default 5M to 50M ) ?

That'd be nice, if possible.
But also in some cases you'd want to reduce it, if someone previously
set up something much too big.

> In current way it will cause a lot of confusing, you set 1000M, but
> system still runs on 5M

It'll give the warning in errorlog/syslog, which is better than the
current behaviour of aborting - that hinders progress even for new
installations.

If you can do a resize up and down, that'd be excellent!

Cheers,
Arjen.
--
Arjen Lentz, Exec.Director @ Open Query (http://openquery.com)
Exceptional Services for MySQL at a fixed budget.

Follow our blog at http://openquery.com/blog/
OurDelta: enhanced builds for MySQL @ http://ourdelta.org

Revision history for this message
Vadim Tkachenko (vadim-tk) wrote :

Yasufumi is going to implement auto-increasing of log_size if value in my.cnf (or in defaults) is bigger than current log file.

Changed in percona-patches:
assignee: nobody → Yasufumi Kinoshita (yasufumi-kinoshita)
Changed in percona-xtradb:
importance: Undecided → Wishlist
status: New → Confirmed
assignee: nobody → Yasufumi Kinoshita (yasufumi-kinoshita)
Revision history for this message
Stewart Smith (stewart) wrote :

All development of XtraDB has moved under the Percona Server project - https://launchpad.net/percona-server - If this bug can be reproduced against current Percona Server, please file this bug against percona-server (you can simply do so by using the "Also affects project" link above).

Thanks,
Stewart Smith
Director of Server Development
Percona.

Changed in percona-xtradb:
status: Confirmed → Won't Fix
Changed in percona-patches:
status: Confirmed → Won't Fix
Stewart Smith (stewart)
Changed in percona-server:
status: New → Triaged
importance: Undecided → Wishlist
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

Fixed by 5.6 online log resizing

Revision history for this message
Shahriyar Rzayev (rzayev-sehriyar) wrote :

Percona now uses JIRA for bug reports so this bug report is migrated to: https://jira.percona.com/browse/PS-2515

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.