~tsarev/percona-server/5.1-install_tests_fix-790199

102.1.1 by kinoyasu
add header and rule, as the first step of the reordering patch for separate release
1
# name       : innodb_expand_undo_slots.patch
2
# introduced : 11 or before
3
# maintainer : Yasufumi
4
#
5
#!!! notice !!!
6
# Any small change to this file in the main branch
7
# should be done or reviewed by the maintainer!
1 by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7
8
diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/handler/ha_innodb.cc
9
--- a/storage/innodb_plugin/handler/ha_innodb.cc	2010-04-29 16:06:22.000000000 +0900
10
+++ b/storage/innodb_plugin/handler/ha_innodb.cc	2010-04-29 16:06:59.000000000 +0900
9 by kinoyasu
port for 5.1.47-1.0.8
11
@@ -165,6 +165,7 @@
1 by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7
12
 #endif /* UNIV_LOG_ARCHIVE */
13
 static my_bool	innobase_use_doublewrite		= TRUE;
14
 static my_bool	innobase_use_checksums			= TRUE;
15
+static my_bool	innobase_extra_undoslots		= FALSE;
16
 static my_bool	innobase_locks_unsafe_for_binlog	= FALSE;
17
 static my_bool	innobase_rollback_on_timeout		= FALSE;
18
 static my_bool	innobase_create_status_file		= FALSE;
208 by Yasufumi Kinoshita
Yasufumi patches and several are ported to 5.1.56; Note: option innodb_stats_method was removed from innodb_stats.patch, because implemented officially. And, bug733317 should be fixed before release
19
@@ -2122,6 +2123,8 @@
1 by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7
20
 		goto error;
21
 	}
22
 
23
+	srv_extra_undoslots = (ibool) innobase_extra_undoslots;
24
+
25
 	/* -------------- Log files ---------------------------*/
26
 
27
 	/* The default dir for log files is the datadir of MySQL */
208 by Yasufumi Kinoshita
Yasufumi patches and several are ported to 5.1.56; Note: option innodb_stats_method was removed from innodb_stats.patch, because implemented officially. And, bug733317 should be fixed before release
28
@@ -10785,6 +10788,13 @@
1 by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7
29
   "The common part for InnoDB table spaces.",
30
   NULL, NULL, NULL);
31
 
32
+static MYSQL_SYSVAR_BOOL(extra_undoslots, innobase_extra_undoslots,
33
+  PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
34
+  "Enable to use about 4000 undo slots instead of default 1024. "
35
+  "#### Attention: Once you enable this parameter, "
36
+  "don't use the datafile for normal mysqld or ibbackup! ####",
37
+  NULL, NULL, FALSE);
38
+
39
 static MYSQL_SYSVAR_BOOL(doublewrite, innobase_use_doublewrite,
40
   PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
41
   "Enable InnoDB doublewrite buffer (enabled by default). "
208 by Yasufumi Kinoshita
Yasufumi patches and several are ported to 5.1.56; Note: option innodb_stats_method was removed from innodb_stats.patch, because implemented officially. And, bug733317 should be fixed before release
42
@@ -11177,6 +11187,7 @@
1 by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7
43
   MYSQL_SYSVAR(data_file_path),
44
   MYSQL_SYSVAR(data_home_dir),
45
   MYSQL_SYSVAR(doublewrite),
46
+  MYSQL_SYSVAR(extra_undoslots),
47
   MYSQL_SYSVAR(fast_shutdown),
48
   MYSQL_SYSVAR(file_io_threads),
49
   MYSQL_SYSVAR(read_io_threads),
50
diff -ruN a/storage/innodb_plugin/handler/innodb_patch_info.h b/storage/innodb_plugin/handler/innodb_patch_info.h
51
--- a/storage/innodb_plugin/handler/innodb_patch_info.h	2010-04-29 16:06:22.000000000 +0900
52
+++ b/storage/innodb_plugin/handler/innodb_patch_info.h	2010-04-29 16:06:59.000000000 +0900
53
@@ -28,5 +28,6 @@
54
 {"innodb_io","Improvements to InnoDB IO","","http://www.percona.com/docs/wiki/percona-xtradb"},
55
 {"innodb_opt_lru_count","Fix of buffer_pool mutex","Decreases contention on buffer_pool mutex on LRU operations","http://www.percona.com/docs/wiki/percona-xtradb"},
56
 {"innodb_buffer_pool_pages","Information of buffer pool content","","http://www.percona.com/docs/wiki/percona-xtradb"},
57
+{"innodb_expand_undo_slots","expandable maximum number of undo slots","from 1024 (default) to about 4000","http://www.percona.com/docs/wiki/percona-xtradb"},
58
 {NULL, NULL, NULL, NULL}
59
 };
60
diff -ruN a/storage/innodb_plugin/include/srv0srv.h b/storage/innodb_plugin/include/srv0srv.h
61
--- a/storage/innodb_plugin/include/srv0srv.h	2010-04-29 15:55:25.000000000 +0900
62
+++ b/storage/innodb_plugin/include/srv0srv.h	2010-04-29 16:06:59.000000000 +0900
63
@@ -112,6 +112,8 @@
64
 extern ulint*	srv_data_file_sizes;
65
 extern ulint*	srv_data_file_is_raw_partition;
66
 
67
+extern ibool	srv_extra_undoslots;
68
+
69
 extern ibool	srv_auto_extend_last_data_file;
70
 extern ulint	srv_last_file_size_max;
71
 extern char**	srv_log_group_home_dirs;
72
diff -ruN a/storage/innodb_plugin/include/trx0rseg.h b/storage/innodb_plugin/include/trx0rseg.h
73
--- a/storage/innodb_plugin/include/trx0rseg.h	2010-04-06 23:07:13.000000000 +0900
74
+++ b/storage/innodb_plugin/include/trx0rseg.h	2010-04-29 16:06:59.000000000 +0900
75
@@ -123,8 +123,11 @@
76
 	trx_rseg_t*	rseg);		/* in, own: instance to free */
77
 
78
 
79
+/* Real max value may be 4076 in usual. But reserve 4 slot for safety or etc... */
80
+#define TRX_RSEG_N_EXTRA_SLOTS	(((UNIV_PAGE_SIZE - (FIL_PAGE_DATA + FIL_PAGE_DATA_END + TRX_RSEG_UNDO_SLOTS)) / TRX_RSEG_SLOT_SIZE) - 4)
81
+
82
 /* Number of undo log slots in a rollback segment file copy */
83
-#define TRX_RSEG_N_SLOTS	(UNIV_PAGE_SIZE / 16)
84
+#define TRX_RSEG_N_SLOTS	(srv_extra_undoslots ? TRX_RSEG_N_EXTRA_SLOTS : (UNIV_PAGE_SIZE / 16))
85
 
86
 /* Maximum number of transactions supported by a single rollback segment */
87
 #define TRX_RSEG_MAX_N_TRXS	(TRX_RSEG_N_SLOTS / 2)
88
diff -ruN a/storage/innodb_plugin/srv/srv0srv.c b/storage/innodb_plugin/srv/srv0srv.c
89
--- a/storage/innodb_plugin/srv/srv0srv.c	2010-04-29 15:55:25.000000000 +0900
90
+++ b/storage/innodb_plugin/srv/srv0srv.c	2010-04-29 16:06:59.000000000 +0900
91
@@ -142,6 +142,8 @@
92
 /* size in database pages */
93
 UNIV_INTERN ulint*	srv_data_file_sizes = NULL;
94
 
95
+UNIV_INTERN ibool	srv_extra_undoslots = FALSE;
96
+
97
 /* if TRUE, then we auto-extend the last data file */
98
 UNIV_INTERN ibool	srv_auto_extend_last_data_file	= FALSE;
99
 /* if != 0, this tells the max size auto-extending may increase the
100
diff -ruN a/storage/innodb_plugin/trx/trx0undo.c b/storage/innodb_plugin/trx/trx0undo.c
101
--- a/storage/innodb_plugin/trx/trx0undo.c	2010-04-06 23:07:14.000000000 +0900
102
+++ b/storage/innodb_plugin/trx/trx0undo.c	2010-04-29 16:06:59.000000000 +0900
133 by kinoyasu
port maintainer-Yasufumi patches for 5.1.52
103
@@ -1395,9 +1395,47 @@
1 by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7
104
 	rseg_header = trx_rsegf_get_new(rseg->space, rseg->zip_size,
105
 					rseg->page_no, &mtr);
106
 
107
+	if (!srv_extra_undoslots) {
108
+		/* uses direct call for avoid "Assertion failure" */
109
+		//page_no = trx_rsegf_get_nth_undo(rseg_header, TRX_RSEG_N_EXTRA_SLOTS - 1, &mtr);
110
+		page_no = mtr_read_ulint(rseg_header + TRX_RSEG_UNDO_SLOTS
111
+					 + (TRX_RSEG_N_EXTRA_SLOTS - 1) * TRX_RSEG_SLOT_SIZE,
112
+					 MLOG_4BYTES, &mtr);
113
+		if (page_no != 0) {
114
+			/* check extended slots are not used */
115
+			for (i = TRX_RSEG_N_SLOTS; i < TRX_RSEG_N_EXTRA_SLOTS; i++) {
116
+				/* uses direct call for avoid "Assertion failure" */
117
+				page_no = mtr_read_ulint(rseg_header + TRX_RSEG_UNDO_SLOTS
118
+							 + i * TRX_RSEG_SLOT_SIZE,
119
+							 MLOG_4BYTES, &mtr);
137 by kinoyasu
first aid for bug640576; but not perfect
120
+				if (page_no != 0 && page_no != FIL_NULL) {
1 by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7
121
+					srv_extra_undoslots = TRUE;
122
+					fprintf(stderr,
123
+"InnoDB: Error: innodb_extra_undoslots option is disabled, but it was enabled before.\n"
124
+"InnoDB: The datafile is not normal for mysqld and disabled innodb_extra_undoslots.\n"
125
+"InnoDB: Enable innodb_extra_undoslots if it was enabled before, and\n"
126
+"InnoDB: ### don't use this datafile with other mysqld or ibbackup! ###\n"
127
+"InnoDB: Cannot continue operation for the safety. Calling exit(1).\n");
128
+					exit(1);
129
+				}
130
+			}
131
+			fprintf(stderr,
132
+"InnoDB: Warning: innodb_extra_undoslots option is disabled, but it was  enabled before.\n"
133
+"InnoDB: But extended undo slots seem not used, so continue operation.\n");
134
+		}
135
+	}
136
+
137
 	for (i = 0; i < TRX_RSEG_N_SLOTS; i++) {
138
 		page_no = trx_rsegf_get_nth_undo(rseg_header, i, &mtr);
139
 
140
+		/* If it was not initialized when the datafile created,
141
+		page_no will be 0 for the extended slots after that */
142
+
143
+		if (page_no == 0) {
144
+			page_no = FIL_NULL;
145
+			trx_rsegf_set_nth_undo(rseg_header, i, page_no, &mtr);
146
+		}
147
+
148
 		/* In forced recovery: try to avoid operations which look
149
 		at database pages; undo logs are rapidly changing data, and
150
 		the probability that they are in an inconsistent state is