My favorites | Sign in
Google
                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
diff --recursive -u orig5037/innobase/include/srv0srv.h mysql-5.0.37/innobase/include/srv0srv.h
--- orig5037/innobase/include/srv0srv.h 2007-03-05 11:21:39.000000000 -0800
+++ mysql-5.0.37/innobase/include/srv0srv.h 2008-10-02 06:10:22.000000000 -0700
@@ -79,6 +79,10 @@
extern ulint srv_log_buffer_size;
extern ulong srv_flush_log_at_trx_commit;

+/* When this event is reset we do not allow any file writes to
+take place. */
+extern os_event_t srv_allow_writes_event;
+
extern byte srv_latin1_ordering[256];/* The sort order table of the latin1
character set */
extern ulint srv_pool_size;
diff --recursive -u orig5037/innobase/os/os0file.c mysql-5.0.37/innobase/os/os0file.c
--- orig5037/innobase/os/os0file.c 2007-03-05 11:21:03.000000000 -0800
+++ mysql-5.0.37/innobase/os/os0file.c 2008-10-02 06:10:22.000000000 -0700
@@ -518,6 +518,7 @@
/*========================*/
/* out: temporary file handle, or NULL on error */
{
+ os_event_wait(srv_allow_writes_event);
#ifdef __NETWARE__
FILE* file = tmpfile();
#else /* __NETWARE__ */
@@ -832,6 +833,7 @@
ibool fail_if_exists) /* in: if TRUE, pre-existing directory
is treated as an error. */
{
+ os_event_wait(srv_allow_writes_event);
#ifdef __WIN__
BOOL rcode;

@@ -883,6 +885,8 @@
OS_FILE_READ_WRITE */
ibool* success)/* out: TRUE if succeed, FALSE if error */
{
+ if (create_mode != OS_FILE_OPEN && create_mode != OS_FILE_OPEN_RAW)
+ os_event_wait(srv_allow_writes_event);
#ifdef __WIN__
os_file_t file;
DWORD create_flag;
@@ -1024,6 +1028,8 @@
used by a backup program reading the file */
ibool* success)/* out: TRUE if succeed, FALSE if error */
{
+ if (create_mode != OS_FILE_OPEN && create_mode != OS_FILE_OPEN_RAW)
+ os_event_wait(srv_allow_writes_event);
#ifdef __WIN__
os_file_t file;
DWORD create_flag;
@@ -1145,6 +1151,8 @@
ulint type, /* in: OS_DATA_FILE or OS_LOG_FILE */
ibool* success)/* out: TRUE if succeed, FALSE if error */
{
+ if (create_mode != OS_FILE_OPEN && create_mode != OS_FILE_OPEN_RAW)
+ os_event_wait(srv_allow_writes_event);
#ifdef __WIN__
os_file_t file;
DWORD share_mode = FILE_SHARE_READ;
@@ -1359,6 +1367,7 @@
/* out: TRUE if success */
const char* name) /* in: file path as a null-terminated string */
{
+ os_event_wait(srv_allow_writes_event);
#ifdef __WIN__
BOOL ret;
ulint count = 0;
@@ -1420,6 +1429,7 @@
/* out: TRUE if success */
const char* name) /* in: file path as a null-terminated string */
{
+ os_event_wait(srv_allow_writes_event);
#ifdef __WIN__
BOOL ret;
ulint count = 0;
@@ -1485,6 +1495,7 @@
string */
const char* newpath)/* in: new file path */
{
+ os_event_wait(srv_allow_writes_event);
#ifdef __WIN__
BOOL ret;

@@ -1755,6 +1766,7 @@
/* out: TRUE if success */
FILE* file) /* in: file to be truncated */
{
+ os_event_wait(srv_allow_writes_event);
#ifdef __WIN__
HANDLE h = (HANDLE) _get_osfhandle(fileno(file));
return(SetEndOfFile(h));
@@ -1772,6 +1784,7 @@
/* out: TRUE if success */
os_file_t file) /* in, own: handle to a file */
{
+ os_event_wait(srv_allow_writes_event);
#ifdef __WIN__
BOOL ret;

@@ -2317,6 +2330,7 @@
offset */
ulint n) /* in: number of bytes to write */
{
+ os_event_wait(srv_allow_writes_event);
#ifdef __WIN__
BOOL ret;
DWORD len;
diff --recursive -u orig5037/innobase/srv/srv0srv.c mysql-5.0.37/innobase/srv/srv0srv.c
--- orig5037/innobase/srv/srv0srv.c 2007-03-05 11:21:12.000000000 -0800
+++ mysql-5.0.37/innobase/srv/srv0srv.c 2008-10-02 06:10:28.000000000 -0700
@@ -115,6 +115,8 @@
ulint srv_log_buffer_size = ULINT_MAX; /* size in database pages */
ulong srv_flush_log_at_trx_commit = 1;

+os_event_t srv_allow_writes_event;
+
byte srv_latin1_ordering[256] /* The sort order table of the latin1
character set. The following table is
the MySQL order as of Feb 10th, 2002 */
@@ -951,8 +953,17 @@
conc_slot->reserved = FALSE;
conc_slot->event = os_event_create(NULL);
ut_a(conc_slot->event);
- }
-}
+ }
+
+ /*
+ Writes have to be enabled on init or else we hang. Thus, we
+ always set the event here regardless of innobase_disallow_writes.
+ That flag will always be 0 at this point because it isn't settable
+ via my.cnf or command line arg.
+ */
+ srv_allow_writes_event = os_event_create(NULL);
+ os_event_set(srv_allow_writes_event);
+}

/*************************************************************************
Frees the OS fast mutex created in srv_init(). */
diff --recursive -u orig5037/sql/ha_innodb.cc mysql-5.0.37/sql/ha_innodb.cc
--- orig5037/sql/ha_innodb.cc 2007-03-05 11:21:41.000000000 -0800
+++ mysql-5.0.37/sql/ha_innodb.cc 2008-10-02 06:10:28.000000000 -0700
@@ -174,6 +174,7 @@
my_bool innobase_locks_unsafe_for_binlog = FALSE;
my_bool innobase_rollback_on_timeout = FALSE;
my_bool innobase_create_status_file = FALSE;
+my_bool innobase_disallow_writes = FALSE; /* Must always init to FALSE. */

static char *internal_innobase_data_file_path = NULL;

@@ -7322,4 +7323,17 @@
(cursor_view_t*) curview);
}

+/**************************************************************************
+Controls whether InnoDB is in no-write mode. */
+
+void
+innobase_set_disallow_writes(my_bool disallow_writes)
+{
+ ut_a(srv_allow_writes_event);
+ if (disallow_writes)
+ os_event_reset(srv_allow_writes_event);
+ else
+ os_event_set(srv_allow_writes_event);
+}
+
#endif /* HAVE_INNOBASE_DB */
diff --recursive -u orig5037/sql/ha_innodb.h mysql-5.0.37/sql/ha_innodb.h
--- orig5037/sql/ha_innodb.h 2007-03-05 11:21:41.000000000 -0800
+++ mysql-5.0.37/sql/ha_innodb.h 2008-10-02 06:10:22.000000000 -0700
@@ -216,7 +216,8 @@
innobase_use_native_aio,
innobase_file_per_table, innobase_locks_unsafe_for_binlog,
innobase_rollback_on_timeout,
- innobase_create_status_file;
+ innobase_create_status_file,
+ innobase_disallow_writes;
extern my_bool innobase_very_fast_shutdown; /* set this to 1 just before
calling innobase_end() if you want
InnoDB to shut down without
@@ -334,3 +335,11 @@
innobase_set_cursor_view(
/*=====================*/
void* curview); /* in: Consistent read view to be set */
+
+/***********************************************************************
+Toggle the dynamic option of putting InnoDB into no-write mode. */
+
+void
+innobase_set_disallow_writes(
+/*=========================*/
+ my_bool disallow_writes); /* in: True to turn off writing */
diff --recursive -u orig5037/sql/set_var.cc mysql-5.0.37/sql/set_var.cc
--- orig5037/sql/set_var.cc 2007-03-05 11:21:24.000000000 -0800
+++ mysql-5.0.37/sql/set_var.cc 2008-10-02 06:10:22.000000000 -0700
@@ -116,6 +116,7 @@
static void fix_thd_mem_root(THD *thd, enum_var_type type);
static void fix_trans_mem_root(THD *thd, enum_var_type type);
static void fix_server_id(THD *thd, enum_var_type type);
+static void after_update_disallow_writes(THD *thd, enum_var_type type);
static KEY_CACHE *create_key_cache(const char *name, uint length);
void fix_sql_mode_var(THD *thd, enum_var_type type);
static byte *get_error_count(THD *thd);
@@ -431,6 +432,9 @@
&SV::net_wait_timeout);

#ifdef HAVE_INNOBASE_DB
+sys_var_bool_ptr sys_innodb_disallow_writes("innodb_disallow_writes",
+ &innobase_disallow_writes,
+ after_update_disallow_writes);
sys_var_long_ptr sys_innodb_fast_shutdown("innodb_fast_shutdown",
&innobase_fast_shutdown);
sys_var_long_ptr sys_innodb_max_dirty_pages_pct("innodb_max_dirty_pages_pct",
@@ -777,6 +781,7 @@
&sys_version_compile_machine,
&sys_version_compile_os,
#ifdef HAVE_INNOBASE_DB
+ &sys_innodb_disallow_writes,
&sys_innodb_fast_shutdown,
&sys_innodb_max_dirty_pages_pct,
&sys_innodb_max_purge_lag,
@@ -894,6 +899,8 @@
{sys_innodb_concurrency_tickets.name, (char*) &sys_innodb_concurrency_tickets, SHOW_SYS},
{"innodb_data_file_path", (char*) &innobase_data_file_path, SHOW_CHAR_PTR},
{"innodb_data_home_dir", (char*) &innobase_data_home_dir, SHOW_CHAR_PTR},
+ {sys_innodb_disallow_writes.name, (char*) &sys_innodb_disallow_writes,
+ SHOW_SYS},
{"innodb_doublewrite", (char*) &innobase_use_doublewrite, SHOW_MY_BOOL},
{sys_innodb_fast_shutdown.name,(char*) &sys_innodb_fast_shutdown, SHOW_SYS},
{"innodb_file_io_threads", (char*) &innobase_file_io_threads, SHOW_LONG },
@@ -1426,6 +1433,17 @@
server_id_supplied = 1;
}

+#ifdef HAVE_INNOBASE_DB
+static void after_update_disallow_writes(THD *thd, enum_var_type type)
+{
+ DBUG_ENTER("after_update_disallow_writes");
+ DBUG_PRINT("info",("innobase_disallow_writes=%d", innobase_disallow_writes));
+
+ innobase_set_disallow_writes(innobase_disallow_writes);
+
+ DBUG_VOID_RETURN;
+}
+#endif

sys_var_long_ptr::
sys_var_long_ptr(const char *name_arg, ulong *value_ptr,
diff --recursive -u orig5037/sql/set_var.h mysql-5.0.37/sql/set_var.h
--- orig5037/sql/set_var.h 2007-03-05 11:21:22.000000000 -0800
+++ mysql-5.0.37/sql/set_var.h 2008-10-02 06:10:22.000000000 -0700
@@ -142,8 +142,9 @@
{
public:
my_bool *value;
- sys_var_bool_ptr(const char *name_arg, my_bool *value_arg)
- :sys_var(name_arg),value(value_arg)
+ sys_var_bool_ptr(const char *name_arg, my_bool *value_arg,
+ sys_after_update_func after_update_arg= NULL)
+ :sys_var(name_arg, after_update_arg),value(value_arg)
{}
bool check(THD *thd, set_var *var)
{
Show details Hide details

Change log

r131 by mdcallag on Oct 02, 2008   Diff
innodb_disallow_writes
Go to: 
Project members, sign in to write a code review

Older revisions

All revisions of this file

File info

Size: 9830 bytes, 265 lines