/*********************************************************************//**
Write the meta data (index user fields) config file.
@return DB_SUCCESS or error code. */ static MY_ATTRIBUTE((nonnull, warn_unused_result))
dberr_t
row_quiesce_write_index_fields( /*===========================*/ const dict_index_t* index, /*!< in: write the meta data for
this index */
FILE* file, /*!< in: file to write to */
THD* thd) /*!< in/out: session */
{
byte row[sizeof(ib_uint32_t) * 3];
for (ulint i = 0; i < index->n_fields; ++i) {
byte* ptr = row; const dict_field_t* field = &index->fields[i];
/* Since maximum fixed length can be DICT_ANTELOPE_MAX_INDEX_COL_LEN,InnoDB canusethe0thbittostorethe
field descending information */
mach_write_to_4(ptr, field->fixed_len
| uint32_t(field->descending) << 31);
ptr += 4;
constchar* field_name = field->name ? field->name : ""; /* Include the NUL byte in the length. */
uint32_t len = uint32_t(strlen(field_name) + 1);
mach_write_to_4(ptr, len);
/*********************************************************************//**
Write the meta data config file index information.
@return DB_SUCCESS or error code. */ static MY_ATTRIBUTE((nonnull, warn_unused_result))
dberr_t
row_quiesce_write_indexes( /*======================*/ const dict_table_t* table, /*!< in: write the meta data for
this table */
FILE* file, /*!< in: file to write to */
THD* thd) /*!< in/out: session */
{
ulint n_indexes = 0; for (const dict_index_t* index = UT_LIST_GET_FIRST(table->indexes);
index; index = UT_LIST_GET_NEXT(indexes, index)) {
n_indexes += index->is_committed();
}
{
byte row[sizeof(ib_uint32_t)];
/* Write the number of indexes in the table. */
mach_write_to_4(row, n_indexes);
if (fwrite(row, 1, sizeof(row), file) != sizeof(row)) {
ib_senderrf(
thd, IB_LOG_LEVEL_WARN, ER_IO_WRITE_ERROR,
(ulong) errno, strerror(errno), "while writing index count.");
return(DB_IO_ERROR);
}
}
dberr_t err = DB_SUCCESS;
/* Write the index meta data. */ for (const dict_index_t* index = UT_LIST_GET_FIRST(table->indexes);
index != 0 && err == DB_SUCCESS;
index = UT_LIST_GET_NEXT(indexes, index)) {
/* Write the length of the index name.
NUL byte is included in the length. */
ib_uint32_t len = static_cast<ib_uint32_t>(strlen(index->name) + 1);
ut_a(len > 1);
/*********************************************************************//**
Write the meta data (table columns) config file. Serialise the contents of
dict_col_t structure, along with the column name. All fields are serialized
as ib_uint32_t.
@return DB_SUCCESS or error code. */ static MY_ATTRIBUTE((nonnull, warn_unused_result))
dberr_t
row_quiesce_write_table( /*====================*/ const dict_table_t* table, /*!< in: write the meta data for
this table */
FILE* file, /*!< in: file to write to */
THD* thd) /*!< in/out: session */
{
dict_col_t* col;
byte row[sizeof(ib_uint32_t) * 7];
col = table->cols;
for (ulint i = 0; i < table->n_cols; ++i, ++col) {
byte* ptr = row;
/* FIXME: This will not work if mbminlen>4. Thisfieldisalsoredundant,becausethelengths areapropertyofthecharactersetencoding,which
in turn is encodedin prtype above. */
mach_write_to_4(ptr, ulint(col->mbmaxlen * 5 + col->mbminlen));
ptr += sizeof(ib_uint32_t);
/* Write out the column name as [len, byte array]. The len
includes the NUL byte. */
ib_uint32_t len; const Lex_ident_column col_name = dict_table_get_col_name(table, dict_col_get_no(col));
/* Include the NUL byte in the length. */
len = static_cast<ib_uint32_t>(col_name.length + 1);
ut_a(len > 1);
/*********************************************************************//**
Write the meta data config file header.
@return DB_SUCCESS or error code. */ static MY_ATTRIBUTE((nonnull, warn_unused_result))
dberr_t
row_quiesce_write_header( /*=====================*/ const dict_table_t* table, /*!< in: write the meta data for
this table */
FILE* file, /*!< in: file to write to */
THD* thd) /*!< in/out: session */
{
byte value[sizeof(ib_uint32_t)];
/* Write the meta-data version number. */
mach_write_to_4(value, IB_EXPORT_CFG_VERSION_V1);
/*********************************************************************//**
Write the table meta data after quiesce.
@return DB_SUCCESS or error code */
static MY_ATTRIBUTE((nonnull, warn_unused_result))
dberr_t
row_quiesce_write_cfg( /*==================*/
dict_table_t* table, /*!< in: write the meta data for
this table */
THD* thd) /*!< in/out: session */
{
dberr_t err; char name[OS_FILE_MAX_PATH];
if (fflush(file)) {
std::ignore = fclose(file); goto fail;
}
if (fclose(file)) { goto fail;
}
}
return(err);
}
/*********************************************************************//**
Check whether a table has an FTS index defined on it.
@returntrueif an FTS index exists on the table */ static bool
row_quiesce_table_has_fts_index( /*============================*/ const dict_table_t* table) /*!< in: quiesce this table */
{ bool exists = false;
for (const dict_index_t* index = UT_LIST_GET_FIRST(table->indexes);
index != 0;
index = UT_LIST_GET_NEXT(indexes, index)) {
/*********************************************************************//**
Quiesce the tablespace that the table resides in. */ void
row_quiesce_table_start( /*====================*/
dict_table_t* table, /*!< in: quiesce this table */
trx_t* trx) /*!< in/out: transaction/session */
{
ut_a(trx->mysql_thd != 0);
ut_a(srv_n_purge_threads > 0);
ut_ad(!srv_read_only_mode);
ut_ad(!recv_sys.rpo);
ut_a(trx->mysql_thd != 0);
ut_ad(table->space != NULL);
ib::info() << "Sync to disk of " << table->name << " started.";
if (srv_undo_sources) {
purge_sys.stop();
}
while (buf_flush_list_space(table->space)) { if (trx_is_interrupted(trx)) { goto aborted;
}
}
if (!trx_is_interrupted(trx)) { /* Ensure that all asynchronous IO is completed. */
os_aio_wait_until_no_pending_writes(true);
table->space->flush<false>();
if (row_quiesce_write_cfg(table, trx->mysql_thd)
!= DB_SUCCESS) {
ib::warn() << "There was an error writing to the" " meta data file";
} else {
ib::info() << "Table " << table->name
<< " flushed to disk";
}
} else {
aborted:
ib::warn() << "Quiesce aborted!";
}
if (!opt_bootstrap) { /* Remove the .cfg file now that the user has resumed normaloperations.Otherwiseitwillcauseproblemswhen
the user tries to drop the database (remove directory). */ char cfg_name[OS_FILE_MAX_PATH];
ib_senderrf(trx->mysql_thd, IB_LOG_LEVEL_WARN,
ER_NOT_SUPPORTED_YET, "FLUSH TABLES on tables that have an FTS index." " FTS auxiliary tables will not be flushed.");
} elseif (DICT_TF2_FLAG_IS_SET(table, DICT_TF2_FTS_HAS_DOC_ID)) { /* If this flag is set then the table may not have any active
FTS indexes but it will still have the auxiliary tables. */
ib_senderrf(trx->mysql_thd, IB_LOG_LEVEL_WARN,
ER_NOT_SUPPORTED_YET, "FLUSH TABLES on a table that had an FTS index," " created on a hidden column, the" " auxiliary tables haven't been dropped as yet." " FTS auxiliary tables will not be flushed.");
}
for (dict_index_t* index = dict_table_get_next_index(clust_index);
index != NULL;
index = dict_table_get_next_index(index)) {
index->lock.x_lock(SRW_LOCK_CALL);
}
clust_index->lock.x_lock(SRW_LOCK_CALL);
switch (state) { case QUIESCE_START: break;
case QUIESCE_COMPLETE:
ut_a(table->quiesce == QUIESCE_START); break;
case QUIESCE_NONE:
ut_a(table->quiesce == QUIESCE_COMPLETE); break;
}
table->quiesce = state;
for (dict_index_t* index = dict_table_get_first_index(table);
index != NULL;
index = dict_table_get_next_index(index)) {
index->lock.x_unlock();
}
return(DB_SUCCESS);
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet am 2026-10-08)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.