30 #include "row0quiesce.ic"
40 static __attribute__((nonnull, warn_unused_result))
42 row_quiesce_write_index_fields(
49 byte row[
sizeof(ib_uint32_t) * 2];
51 for (ulint
i = 0;
i < index->n_fields; ++
i) {
56 ptr +=
sizeof(ib_uint32_t);
60 DBUG_EXECUTE_IF(
"ib_export_io_write_failure_9",
61 close(fileno(file)););
63 if (fwrite(row, 1,
sizeof(row), file) !=
sizeof(row)) {
66 thd, IB_LOG_LEVEL_WARN, ER_IO_WRITE_ERROR,
67 errno, strerror(errno),
68 "while writing index fields.");
74 ib_uint32_t len = strlen(field->
name) + 1;
79 DBUG_EXECUTE_IF(
"ib_export_io_write_failure_10",
80 close(fileno(file)););
82 if (fwrite(row, 1,
sizeof(len), file) !=
sizeof(len)
83 || fwrite(field->
name, 1, len, file) != len) {
86 thd, IB_LOG_LEVEL_WARN, ER_IO_WRITE_ERROR,
87 errno, strerror(errno),
88 "while writing index column.");
100 static __attribute__((nonnull, warn_unused_result))
102 row_quiesce_write_indexes(
110 byte row[
sizeof(ib_uint32_t)];
115 DBUG_EXECUTE_IF(
"ib_export_io_write_failure_11",
116 close(fileno(file)););
118 if (fwrite(row, 1,
sizeof(row), file) !=
sizeof(row)) {
120 thd, IB_LOG_LEVEL_WARN, ER_IO_WRITE_ERROR,
121 errno, strerror(errno),
122 "while writing index count.");
132 index != 0 && err == DB_SUCCESS;
136 byte row[
sizeof(index_id_t)
137 +
sizeof(ib_uint32_t) * 8];
141 ut_ad(
sizeof(index_id_t) == 8);
143 ptr +=
sizeof(index_id_t);
146 ptr +=
sizeof(ib_uint32_t);
149 ptr +=
sizeof(ib_uint32_t);
152 ptr +=
sizeof(ib_uint32_t);
155 ptr +=
sizeof(ib_uint32_t);
158 ptr +=
sizeof(ib_uint32_t);
161 ptr +=
sizeof(ib_uint32_t);
164 ptr +=
sizeof(ib_uint32_t);
168 DBUG_EXECUTE_IF(
"ib_export_io_write_failure_12",
169 close(fileno(file)););
171 if (fwrite(row, 1,
sizeof(row), file) !=
sizeof(row)) {
174 thd, IB_LOG_LEVEL_WARN, ER_IO_WRITE_ERROR,
175 errno, strerror(errno),
176 "while writing index meta-data.");
183 ib_uint32_t len = strlen(
index->name) + 1;
188 DBUG_EXECUTE_IF(
"ib_export_io_write_failure_1",
189 close(fileno(file)););
191 if (fwrite(row, 1,
sizeof(len), file) !=
sizeof(len)
192 || fwrite(
index->name, 1, len, file) != len) {
195 thd, IB_LOG_LEVEL_WARN, ER_IO_WRITE_ERROR,
196 errno, strerror(errno),
197 "while writing index name.");
202 err = row_quiesce_write_index_fields(
index, file, thd);
213 static __attribute__((nonnull, warn_unused_result))
215 row_quiesce_write_table(
223 byte row[
sizeof(ib_uint32_t) * 7];
227 for (ulint
i = 0;
i < table->n_cols; ++
i, ++col) {
231 ptr +=
sizeof(ib_uint32_t);
234 ptr +=
sizeof(ib_uint32_t);
237 ptr +=
sizeof(ib_uint32_t);
240 ptr +=
sizeof(ib_uint32_t);
243 ptr +=
sizeof(ib_uint32_t);
246 ptr +=
sizeof(ib_uint32_t);
250 DBUG_EXECUTE_IF(
"ib_export_io_write_failure_2",
251 close(fileno(file)););
253 if (fwrite(row, 1,
sizeof(row), file) !=
sizeof(row)) {
255 thd, IB_LOG_LEVEL_WARN, ER_IO_WRITE_ERROR,
256 errno, strerror(errno),
257 "while writing table column data.");
265 const char* col_name;
270 len = strlen(col_name) + 1;
275 DBUG_EXECUTE_IF(
"ib_export_io_write_failure_3",
276 close(fileno(file)););
278 if (fwrite(row, 1,
sizeof(len), file) !=
sizeof(len)
279 || fwrite(col_name, 1, len, file) != len) {
282 thd, IB_LOG_LEVEL_WARN, ER_IO_WRITE_ERROR,
283 errno, strerror(errno),
284 "while writing column name.");
296 static __attribute__((nonnull, warn_unused_result))
298 row_quiesce_write_header(
305 byte value[
sizeof(ib_uint32_t)];
310 DBUG_EXECUTE_IF(
"ib_export_io_write_failure_4", close(fileno(file)););
312 if (fwrite(&value, 1,
sizeof(value), file) !=
sizeof(value)) {
314 thd, IB_LOG_LEVEL_WARN, ER_IO_WRITE_ERROR,
315 errno, strerror(errno),
316 "while writing meta-data version number.");
327 static const char NullHostname[] =
"Hostname unknown";
330 "Unable to determine server hostname.");
332 hostname = NullHostname;
336 len = strlen(hostname) + 1;
339 DBUG_EXECUTE_IF(
"ib_export_io_write_failure_5", close(fileno(file)););
341 if (fwrite(&value, 1,
sizeof(value), file) !=
sizeof(value)
342 || fwrite(hostname, 1, len, file) != len) {
345 thd, IB_LOG_LEVEL_WARN, ER_IO_WRITE_ERROR,
346 errno, strerror(errno),
347 "while writing hostname.");
353 ut_a(table->name != 0);
354 len = strlen(table->name) + 1;
359 DBUG_EXECUTE_IF(
"ib_export_io_write_failure_6", close(fileno(file)););
361 if (fwrite(&value, 1,
sizeof(value), file) !=
sizeof(value)
362 || fwrite(table->name, 1, len, file) != len) {
365 thd, IB_LOG_LEVEL_WARN, ER_IO_WRITE_ERROR,
366 errno, strerror(errno),
367 "while writing table name.");
372 byte row[
sizeof(ib_uint32_t) * 3];
377 DBUG_EXECUTE_IF(
"ib_export_io_write_failure_7", close(fileno(file)););
379 if (fwrite(row, 1,
sizeof(ib_uint64_t), file) !=
sizeof(ib_uint64_t)) {
381 thd, IB_LOG_LEVEL_WARN, ER_IO_WRITE_ERROR,
382 errno, strerror(errno),
383 "while writing table autoinc value.");
392 ptr +=
sizeof(ib_uint32_t);
396 ptr +=
sizeof(ib_uint32_t);
401 DBUG_EXECUTE_IF(
"ib_export_io_write_failure_8", close(fileno(file)););
403 if (fwrite(row, 1,
sizeof(row), file) !=
sizeof(row)) {
405 thd, IB_LOG_LEVEL_WARN, ER_IO_WRITE_ERROR,
406 errno, strerror(errno),
407 "while writing table meta-data.");
418 static __attribute__((nonnull, warn_unused_result))
420 row_quiesce_write_cfg(
427 char name[OS_FILE_MAX_PATH];
431 ib_logf(IB_LOG_LEVEL_INFO,
"Writing table metadata to '%s'", name);
433 FILE* file = fopen(name,
"w+b");
436 ib_errf(thd, IB_LOG_LEVEL_WARN, ER_CANT_CREATE_FILE,
437 name, errno, strerror(errno));
441 err = row_quiesce_write_header(table, file, thd);
443 if (err == DB_SUCCESS) {
444 err = row_quiesce_write_table(table, file, thd);
447 if (err == DB_SUCCESS) {
448 err = row_quiesce_write_indexes(table, file, thd);
451 if (fflush(file) != 0) {
459 thd, IB_LOG_LEVEL_WARN, ER_IO_WRITE_ERROR,
460 errno, strerror(errno), msg);
463 if (fclose(file) != 0) {
470 thd, IB_LOG_LEVEL_WARN, ER_IO_WRITE_ERROR,
471 errno, strerror(errno), msg);
483 row_quiesce_table_has_fts_index(
495 if (
index->type & DICT_FTS) {
516 ut_a(srv_n_purge_threads > 0);
524 table_name,
sizeof(table_name), table->
name, FALSE);
527 "Sync to disk of '%s' started.", table_name);
535 for (ulint count = 0;
541 "Merging change buffer entries for '%s'",
552 ib_logf(IB_LOG_LEVEL_WARN,
"Quiesce aborted!");
554 }
else if (row_quiesce_write_cfg(table, trx->
mysql_thd)
558 "There was an error writing to the "
562 "Table '%s' flushed to disk", table_name);
565 ib_logf(IB_LOG_LEVEL_WARN,
"Quiesce aborted!");
569 ut_a(err == DB_SUCCESS);
582 char table_name[MAX_FULL_NAME_LEN + 1];
587 table_name,
sizeof(table_name), table->
name, FALSE);
597 "Waiting for quiesce of '%s' to complete",
610 char cfg_name[OS_FILE_MAX_PATH];
614 os_file_delete_if_exists(innodb_file_data_key, cfg_name);
617 "Deleting the meta-data file '%s'", cfg_name);
624 ut_a(err == DB_SUCCESS);
638 ut_a(srv_n_purge_threads > 0);
643 IB_LOG_LEVEL_WARN, ER_READ_ONLY_MODE);
647 }
else if (table->
space == TRX_SYS_SPACE) {
649 char table_name[MAX_FULL_NAME_LEN + 1];
652 table_name,
sizeof(table_name), table->
name, FALSE);
655 ER_TABLE_IN_SYSTEM_TABLESPACE, table_name);
658 }
else if (row_quiesce_table_has_fts_index(table)) {
661 ER_NOT_SUPPORTED_YET,
662 "FLUSH TABLES on tables that have an FTS index. "
663 "FTS auxiliary tables will not be flushed.");
670 ER_NOT_SUPPORTED_YET,
671 "FLUSH TABLES on a table that had an FTS index, "
672 "created on a hidden column, the "
673 "auxiliary tables haven't been dropped as yet. "
674 "FTS auxiliary tables will not be flushed.");
677 row_mysql_lock_data_dictionary(trx);