Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PXB-3034 Reduce the time the instance remains under lock #1530

Open
wants to merge 46 commits into
base: reducedlock-trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
dec6cab
PXB-3034 - Make --lock-ddl option an ENUM
altmannmarcelo Nov 6, 2023
464c7b6
PXB-3034 - Add DDL tracking to xtrabackup
altmannmarcelo Nov 6, 2023
15d6004
PXB-3034 - Handle prepare
altmannmarcelo Nov 28, 2023
c3e0dd6
PXB-3034 - Second phase copy Multi thread
altmannmarcelo Nov 30, 2023
3d34e05
PXB-3034 - Adding test cases
altmannmarcelo Nov 6, 2023
756795d
PXB-3034 - adjust fil_open_for_xtrabackup
altmannmarcelo Dec 20, 2023
56a5adb
modifications
aybek Feb 15, 2024
0f5401d
handle renames during scan
aybek Feb 28, 2024
bedc607
We want to note that table will be copied only after it has been open…
aybek Mar 6, 2024
00ecb25
PXB-3113 : Improve debug sync framework to allow PXB to pause and res…
satya-bodapati Apr 2, 2024
7a81fd0
PXB-3252 : Xtrabackup failed to read page after 10 retries. File ./my…
satya-bodapati Apr 5, 2024
4e50fe9
PXB-3246 : Assertion failure: log0recv.cc:2141:!page || fil_page_type…
satya-bodapati Apr 5, 2024
3925f5b
PXB-3253 : [ERROR] [MY-012592] [InnoDB] Operating system error number…
satya-bodapati Apr 18, 2024
121b023
PXB-3223 : PXB must not allow --lock-ddl=REDUCED when pagetracking is…
satya-bodapati Apr 19, 2024
e71924a
PXB-3120 : Assertion failure: Dir_Walker::is_directory
satya-bodapati Apr 22, 2024
80ea4bb
PXB-3278 : Wrong parsing of MLOG_FILE_ redo log records with lock-ddl…
satya-bodapati Apr 25, 2024
1d1607f
Merge pull request #1552 from satya-bodapati/dev-reducedlock
satya-bodapati Apr 25, 2024
d60a02c
PXB-3281 : With lock-ddl=REDUCED, STL containers used by reduced code…
satya-bodapati Apr 25, 2024
b5f4017
Merge pull request #1553 from satya-bodapati/dev-reducedlock
satya-bodapati Apr 25, 2024
17121fe
PXB-3241 : Assertion failure: os0file.cc:3416:!exists while taking ba…
satya-bodapati Apr 26, 2024
36f8cbf
Merge pull request #1554 from satya-bodapati/dev-reducedlock
satya-bodapati Apr 26, 2024
d5a4245
PXB-3245 : Assertion failure: fil0fil.cc:2545:err == DB_SUCCESS found…
satya-bodapati Apr 26, 2024
1a6b48a
Merge pull request #1555 from satya-bodapati/dev-reducedlock
satya-bodapati Apr 26, 2024
594da1d
PXB-3280 : undo log truncation causes assertion failure with reduced …
satya-bodapati May 2, 2024
c0302e8
Merge pull request #1556 from satya-bodapati/dev-reducedlock
satya-bodapati May 2, 2024
e95cb93
PXB-3248 Multiple files found for the same tablespace ID
aybek May 15, 2024
4b9f897
Merge pull request #1557 from aybek/dev-reducedlock-trunk
aybek May 15, 2024
caa4040
PXB-3248 Multiple files found for the same tablespace ID
aybek May 15, 2024
23136ed
Merge pull request #1558 from aybek/dev-reducedlock-trunk
aybek May 15, 2024
42cf484
PXB-3248 - Multiple files found for the same tablespace ID
aybek May 29, 2024
0108546
Merge pull request #1566 from aybek/dev-reducedlock-trunk2
aybek May 29, 2024
b8373d5
PXB-3034: Bring back UNIV_DEBUG on debug-sync-thread.
satya-bodapati Jun 7, 2024
d86332a
Merge pull request #1570 from satya-bodapati/dev-reducedlock
satya-bodapati Jun 9, 2024
a8eb932
PXB-3320 : prepare_handle_del_files() fails to delete the .meta and .…
satya-bodapati Jul 5, 2024
fc66022
Merge pull request #1584 from satya-bodapati/dev-reducedlock
satya-bodapati Jul 15, 2024
c7cd826
PXB-3318 : prepare_handle_ren_files(): failed to handle .ren files
satya-bodapati Jul 16, 2024
1ad8fd9
Merge pull request #1585 from satya-bodapati/dev-reducedlock
satya-bodapati Jul 16, 2024
620cd29
PXB-3295 : Undo tablespaces are not tracked properly with lock-ddl=RE…
satya-bodapati Jul 17, 2024
49c8a34
PXB-3295: fix testcase
satya-bodapati Jul 18, 2024
2fe6a4d
Merge pull request #1586 from satya-bodapati/dev-reducedlock
satya-bodapati Jul 18, 2024
f55da87
Follow up fix for PXB-3318: handle rename source and destination as s…
satya-bodapati Jul 18, 2024
596352f
Merge pull request #1587 from satya-bodapati/dev-reducedlock
satya-bodapati Jul 18, 2024
3099f59
PXB-3221 : Assertion failure: page0cur.cc:1177:ib::fatal triggered du…
satya-bodapati Jul 18, 2024
d525604
Merge pull request #1588 from satya-bodapati/dev-reducedlock
satya-bodapati Jul 19, 2024
686c80c
PXB-3331 : Assertion failure: fil0fil.cc:6422:success
satya-bodapati Jul 22, 2024
3b41be9
Merge pull request #1590 from satya-bodapati/dev-reducedlock
satya-bodapati Jul 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
PXB-3221 : Assertion failure: page0cur.cc:1177:ib::fatal triggered du…
…ring prepare/or next server startup

Problem:
--------
If there are tables created in system tablespace and if ALTER ADD INDEX/DROP INDEX is executed before the
backup lock is taken, system tablespace could end up in corrupted state.

This is because this operation is not redologged and we are supposed to recopy the system tablespace files.
But we dont track system tablesapce, neither reopen and recopy them. Hence this issue.

Fix:
----
1. Track system tablespace in the list of tables tracked/backedup
2. Removing tracking for tables in system tablespace except of recopy. Other operations can be played via redolog
3. Reopen system tablespace and recopy them as ibdata1.new/ ibdata2.new
  • Loading branch information
satya-bodapati committed Jul 19, 2024
commit 3099f596a59b0abbb75d3159a2b9ceb444a8ffbe
6 changes: 6 additions & 0 deletions storage/innobase/fsp/fsp0sysspace.cc
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,12 @@ dberr_t SysTablespace::open_or_create(bool is_temp, bool create_new_db,
}
}

// Add system tablespace for tracking purpose. We might have
// to recopy it
if (ddl_tracker && opt_lock_ddl == LOCK_DDL_REDUCED) {
ddl_tracker->add_table_from_ibd_scan(space->id, space->name);
}

return (err);
}
#endif /* !UNIV_HOTBACKUP */
Expand Down
82 changes: 80 additions & 2 deletions storage/innobase/xtrabackup/src/ddl_tracker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ void ddl_tracker_t::add_table_from_ibd_scan(const space_id_t space_id,

void ddl_tracker_t::add_undo_tablespace(const space_id_t space_id,
std::string name) {
ut_ad(fsp_is_undo_tablespace(space_id));

Fil_path::normalize(name);
std::lock_guard<std::mutex> lock(m_ddl_tracker_mutex);
if (is_server_locked()) {
Expand Down Expand Up @@ -122,6 +124,7 @@ void ddl_tracker_t::add_missing_table(std::string path) {
std::lock_guard<std::mutex> lock(m_ddl_tracker_mutex);
missing_tables.insert(path);
}

void ddl_tracker_t::add_create_table_from_redo(const space_id_t space_id,
lsn_t start_lsn,
const char *name) {
Expand All @@ -130,6 +133,12 @@ void ddl_tracker_t::add_create_table_from_redo(const space_id_t space_id,
return;
}

// tables in system tablespace need not be tracked. They can be
// created via redo log
if (fsp_is_system_tablespace(space_id)) {
return;
}

std::string new_space_name = name;
Fil_path::normalize(new_space_name);
if (Fil_path::has_prefix(new_space_name, Fil_path::DOT_SLASH)) {
Expand All @@ -146,6 +155,12 @@ void ddl_tracker_t::add_rename_table_from_redo(const space_id_t space_id,
lsn_t start_lsn,
const char *old_name,
const char *new_name) {
// Rename of tables in system tablespace is only rename in DD. this is
// tracked via redo log
if (fsp_is_system_tablespace(space_id)) {
return;
}

std::string old_space_name{old_name};
std::string new_space_name{new_name};

Expand Down Expand Up @@ -177,6 +192,12 @@ void ddl_tracker_t::add_drop_table_from_redo(const space_id_t space_id,
return;
}

// DROP table in system tablespace is drop indexes. There is no file removal
// this is also tracked/redone from redo
if (fsp_is_system_tablespace(space_id)) {
return;
}

std::string new_space_name{name};
Fil_path::normalize(new_space_name);
if (Fil_path::has_prefix(new_space_name, Fil_path::DOT_SLASH)) {
Expand Down Expand Up @@ -206,6 +227,12 @@ void ddl_tracker_t::add_renamed_table(const space_id_t &space_id,
return;
}

// rename tables in system tablespace is only rename in DD
// tracked via redo. Skip this
if (fsp_is_system_tablespace(space_id)) {
return;
}

Fil_path::normalize(new_name);
if (Fil_path::has_prefix(new_name, Fil_path::DOT_SLASH)) {
new_name.erase(0, 2);
Expand Down Expand Up @@ -381,6 +408,8 @@ void ddl_tracker_t::handle_ddl_operations() {
for (auto &table : recopy_tables) {
if (tables_in_backup.find(table) != tables_in_backup.end()) {
if (renames.find(table) != renames.end()) {
// We never create .del for ibdata*
ut_ad(!fsp_is_system_tablespace(table));
backup_file_printf(
convert_file_name(table, renames[table].first, ".ibd.del").c_str(),
"%s", "");
Expand Down Expand Up @@ -408,6 +437,8 @@ void ddl_tracker_t::handle_ddl_operations() {
continue;
}

// We never create .del for ibdata*
ut_ad(!fsp_is_system_tablespace(table.first));
backup_file_printf(
convert_file_name(table.first, table.second, ".ibd.del").c_str(), "%s",
"");
Expand Down Expand Up @@ -449,8 +480,55 @@ void ddl_tracker_t::handle_ddl_operations() {
table = new_tables.erase(table);
continue;
}
std::tie(err, std::ignore) = fil_open_for_xtrabackup(
table->second, table->second.substr(0, table->second.length() - 4));

if (fsp_is_system_tablespace(table->first)) {
// open system tablespace for recopying
srv_sys_space.shutdown();

srv_sys_space.set_space_id(TRX_SYS_SPACE);

/* Create the filespace flags. */
ulint fsp_flags =
fsp_flags_init(univ_page_size, false, false, false, false);
srv_sys_space.set_flags(fsp_flags);

srv_sys_space.set_name("innodb_system");
srv_sys_space.set_path(srv_data_home);

/* Supports raw devices */
if (!srv_sys_space.parse_params(innobase_data_file_path, true,
xtrabackup_prepare)) {
xb::error() << "Cannot parse system tablespace params";
ut_ad(0);
return;
}
dberr_t err;
page_no_t sum_of_new_sizes;
lsn_t flush_lsn;

std::this_thread::sleep_for(std::chrono::milliseconds(200));

err = srv_sys_space.check_file_spec(false, 0);

if (err != DB_SUCCESS) {
xb::error() << "could not find data files at the specified datadir";
ut_ad(0);
return;
}

err = srv_sys_space.open_or_create(false, false, &sum_of_new_sizes,
&flush_lsn);

if (err != DB_SUCCESS) {
xb::error() << "could not reopen system tablespace";
ut_ad(0);
return;
}

} else {
std::tie(err, std::ignore) = fil_open_for_xtrabackup(
table->second, table->second.substr(0, table->second.length() - 4));
}
table++;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# PXB-3221 : Assertion failure: page0cur.cc:1177:ib::fatal triggered during prepare
. inc/common.sh

require_debug_pxb_version
start_server

$MYSQL $MYSQL_ARGS -Ns -e "CREATE TABLE t1(a INT, KEY k1(a)) TABLESPACE=innodb_system;" test
$MYSQL $MYSQL_ARGS -Ns -e "INSERT INTO t1 VALUES (1),(2),(3),(4)" test
$MYSQL $MYSQL_ARGS -Ns -e "INSERT INTO t1 SELECT * FROM t1" test
$MYSQL $MYSQL_ARGS -Ns -e "INSERT INTO t1 SELECT * FROM t1" test
$MYSQL $MYSQL_ARGS -Ns -e "INSERT INTO t1 SELECT * FROM t1" test
$MYSQL $MYSQL_ARGS -Ns -e "INSERT INTO t1 SELECT * FROM t1" test

innodb_wait_for_flush_all

XB_ERROR_LOG=$topdir/backup.log
BACKUP_DIR=$topdir/backup
rm -rf $BACKUP_DIR
xtrabackup --backup --lock-ddl=REDUCED --target-dir=$BACKUP_DIR \
--debug-sync="ddl_tracker_before_lock_ddl" 2> >( tee $XB_ERROR_LOG)&

job_pid=$!
pid_file=$topdir/backup/xtrabackup_debug_sync
wait_for_xb_to_suspend $pid_file
xb_pid=`cat $pid_file`
echo "backup pid is $job_pid"

mysql -e "ALTER TABLE t1 ADD INDEX k2(a)" test
mysql -e "ALTER TABLE t1 DROP INDEX k1" test
$MYSQL $MYSQL_ARGS -Ns -e "INSERT INTO t1 SELECT * FROM t1" test
$MYSQL $MYSQL_ARGS -Ns -e "INSERT INTO t1 SELECT * FROM t1" test
$MYSQL $MYSQL_ARGS -Ns -e "INSERT INTO t1 SELECT * FROM t1" test


# Resume the xtrabackup process
vlog "Resuming xtrabackup"
kill -SIGCONT $xb_pid
run_cmd wait $job_pid

xtrabackup --prepare --target-dir=$BACKUP_DIR
stop_server

rm -rf $mysql_datadir/*
xtrabackup --copy-back --target-dir=$BACKUP_DIR
start_server
#mysql -e "ALTER TABLE t1 DROP INDEX k1" test
mysql -e "DELETE FROM t1 WHERE a = 2" test
$MYSQL $MYSQL_ARGS -Ns -e "INSERT INTO t1 SELECT * FROM t1" test
$MYSQL $MYSQL_ARGS -Ns -e "INSERT INTO t1 SELECT * FROM t1" test
$MYSQL $MYSQL_ARGS -Ns -e "INSERT INTO t1 SELECT * FROM t1" test
$MYSQL $MYSQL_ARGS -Ns -e "INSERT INTO t1 SELECT * FROM t1" test
mysql -e "DELETE FROM t1 WHERE a = 2" test

stop_server

rm -rf $mysql_datadir $BACKUP_DIR
rm $XB_ERROR_LOG
Loading