Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
08cb5d84
Commit
08cb5d84
authored
Mar 31, 2021
by
Vladislav Vaintroub
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-25221 Do not remove source file, if copy_file() fails in mariabackup --move-back
Remove an incompletely copied destination file.
parent
35ee4aa4
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
61 additions
and
5 deletions
+61
-5
extra/mariabackup/backup_copy.cc
extra/mariabackup/backup_copy.cc
+9
-5
extra/mariabackup/datasink.h
extra/mariabackup/datasink.h
+6
-0
extra/mariabackup/ds_archive.cc
extra/mariabackup/ds_archive.cc
+1
-0
extra/mariabackup/ds_buffer.cc
extra/mariabackup/ds_buffer.cc
+1
-0
extra/mariabackup/ds_compress.cc
extra/mariabackup/ds_compress.cc
+1
-0
extra/mariabackup/ds_local.cc
extra/mariabackup/ds_local.cc
+6
-0
extra/mariabackup/ds_stdout.cc
extra/mariabackup/ds_stdout.cc
+1
-0
extra/mariabackup/ds_tmpfile.cc
extra/mariabackup/ds_tmpfile.cc
+1
-0
extra/mariabackup/ds_xbstream.cc
extra/mariabackup/ds_xbstream.cc
+1
-0
mysql-test/suite/mariabackup/error_during_copyback.result
mysql-test/suite/mariabackup/error_during_copyback.result
+9
-0
mysql-test/suite/mariabackup/error_during_copyback.test
mysql-test/suite/mariabackup/error_during_copyback.test
+25
-0
No files found.
extra/mariabackup/backup_copy.cc
View file @
08cb5d84
...
...
@@ -1066,6 +1066,7 @@ copy_file(ds_ctxt_t *datasink,
ds_file_t
*
dstfile
=
NULL
;
datafile_cur_t
cursor
;
xb_fil_cur_result_t
res
;
DBUG_ASSERT
(
datasink
->
datasink
->
remove
);
const
char
*
dst_path
=
(
xtrabackup_copy_back
||
xtrabackup_move_back
)
?
dst_file_path
:
trim_dotslash
(
dst_file_path
);
...
...
@@ -1091,6 +1092,7 @@ copy_file(ds_ctxt_t *datasink,
if
(
ds_write
(
dstfile
,
cursor
.
buf
,
cursor
.
buf_read
))
{
goto
error
;
}
DBUG_EXECUTE_IF
(
"copy_file_error"
,
errno
=
ENOSPC
;
goto
error
;);
}
if
(
res
==
XB_FIL_CUR_ERROR
)
{
...
...
@@ -1112,6 +1114,7 @@ copy_file(ds_ctxt_t *datasink,
error:
datafile_close
(
&
cursor
);
if
(
dstfile
!=
NULL
)
{
datasink
->
datasink
->
remove
(
dstfile
->
path
);
ds_close
(
dstfile
);
}
...
...
@@ -1156,17 +1159,18 @@ move_file(ds_ctxt_t *datasink,
if
(
my_rename
(
src_file_path
,
dst_file_path_abs
,
MYF
(
0
))
!=
0
)
{
if
(
my_errno
==
EXDEV
)
{
bool
ret
;
ret
=
copy_file
(
datasink
,
src_file_path
,
dst_file_path
,
thread_n
);
/* Fallback to copy/unlink */
if
(
!
copy_file
(
datasink
,
src_file_path
,
dst_file_path
,
thread_n
))
return
false
;
msg
(
thread_n
,
"Removing %s"
,
src_file_path
);
if
(
unlink
(
src_file_path
)
!=
0
)
{
my_strerror
(
errbuf
,
sizeof
(
errbuf
),
errno
);
msg
(
"
Error
: unlink %s failed: %s"
,
msg
(
"
Warning
: unlink %s failed: %s"
,
src_file_path
,
errbuf
);
}
return
(
ret
)
;
return
true
;
}
my_strerror
(
errbuf
,
sizeof
(
errbuf
),
my_errno
);
msg
(
"Can not move file %s to %s: %s"
,
...
...
extra/mariabackup/datasink.h
View file @
08cb5d84
...
...
@@ -50,9 +50,15 @@ struct datasink_struct {
ds_file_t
*
(
*
open
)(
ds_ctxt_t
*
ctxt
,
const
char
*
path
,
MY_STAT
*
stat
);
int
(
*
write
)(
ds_file_t
*
file
,
const
unsigned
char
*
buf
,
size_t
len
);
int
(
*
close
)(
ds_file_t
*
file
);
int
(
*
remove
)(
const
char
*
path
);
void
(
*
deinit
)(
ds_ctxt_t
*
ctxt
);
};
static
inline
int
dummy_remove
(
const
char
*
)
{
return
0
;
}
/* Supported datasink types */
typedef
enum
{
DS_TYPE_STDOUT
,
...
...
extra/mariabackup/ds_archive.cc
View file @
08cb5d84
...
...
@@ -56,6 +56,7 @@ datasink_t datasink_archive = {
&
archive_open
,
&
archive_write
,
&
archive_close
,
&
dummy_remove
,
&
archive_deinit
};
...
...
extra/mariabackup/ds_buffer.cc
View file @
08cb5d84
...
...
@@ -54,6 +54,7 @@ datasink_t datasink_buffer = {
&
buffer_open
,
&
buffer_write
,
&
buffer_close
,
&
dummy_remove
,
&
buffer_deinit
};
...
...
extra/mariabackup/ds_compress.cc
View file @
08cb5d84
...
...
@@ -74,6 +74,7 @@ datasink_t datasink_compress = {
&
compress_open
,
&
compress_write
,
&
compress_close
,
&
dummy_remove
,
&
compress_deinit
};
...
...
extra/mariabackup/ds_local.cc
View file @
08cb5d84
...
...
@@ -44,12 +44,18 @@ static int local_write(ds_file_t *file, const uchar *buf, size_t len);
static
int
local_close
(
ds_file_t
*
file
);
static
void
local_deinit
(
ds_ctxt_t
*
ctxt
);
static
int
local_remove
(
const
char
*
path
)
{
return
unlink
(
path
);
}
extern
"C"
{
datasink_t
datasink_local
=
{
&
local_init
,
&
local_open
,
&
local_write
,
&
local_close
,
&
local_remove
,
&
local_deinit
};
}
...
...
extra/mariabackup/ds_stdout.cc
View file @
08cb5d84
...
...
@@ -39,6 +39,7 @@ datasink_t datasink_stdout = {
&
stdout_open
,
&
stdout_write
,
&
stdout_close
,
&
dummy_remove
,
&
stdout_deinit
};
...
...
extra/mariabackup/ds_tmpfile.cc
View file @
08cb5d84
...
...
@@ -50,6 +50,7 @@ datasink_t datasink_tmpfile = {
&
tmpfile_open
,
&
tmpfile_write
,
&
tmpfile_close
,
&
dummy_remove
,
&
tmpfile_deinit
};
...
...
extra/mariabackup/ds_xbstream.cc
View file @
08cb5d84
...
...
@@ -50,6 +50,7 @@ datasink_t datasink_xbstream = {
&
xbstream_open
,
&
xbstream_write
,
&
xbstream_close
,
&
dummy_remove
,
&
xbstream_deinit
};
...
...
mysql-test/suite/mariabackup/error_during_copyback.result
0 → 100644
View file @
08cb5d84
CREATE TABLE t(i INT) ENGINE INNODB;
INSERT INTO t VALUES(1);
# xtrabackup backup
# xtrabackup prepare
# restart server
SELECT * FROM t;
i
1
DROP TABLE t;
mysql-test/suite/mariabackup/error_during_copyback.test
0 → 100644
View file @
08cb5d84
--
source
include
/
have_debug
.
inc
CREATE
TABLE
t
(
i
INT
)
ENGINE
INNODB
;
INSERT
INTO
t
VALUES
(
1
);
echo
# xtrabackup backup;
let
$targetdir
=
$MYSQLTEST_VARDIR
/
tmp
/
backup
;
--
disable_result_log
exec
$XTRABACKUP
--
defaults
-
file
=
$MYSQLTEST_VARDIR
/
my
.
cnf
--
backup
--
target
-
dir
=
$targetdir
;
--
enable_result_log
echo
# xtrabackup prepare;
--
disable_result_log
exec
$XTRABACKUP
--
prepare
--
target
-
dir
=
$targetdir
;
let
$_datadir
=
`SELECT @@datadir`
;
--
source
include
/
shutdown_mysqld
.
inc
rmdir
$_datadir
;
error
1
;
exec
$XTRABACKUP
--
defaults
-
file
=
$MYSQLTEST_VARDIR
/
my
.
cnf
--
copy
-
back
--
datadir
=
$_datadir
--
target
-
dir
=
$targetdir
--
dbug
=+
d
,
copy_file_error
;
list_files
$_datadir
;
rmdir
$_datadir
;
exec
$XTRABACKUP
--
defaults
-
file
=
$MYSQLTEST_VARDIR
/
my
.
cnf
--
copy
-
back
--
datadir
=
$_datadir
--
target
-
dir
=
$targetdir
;
echo
# restart server;
--
source
include
/
start_mysqld
.
inc
SELECT
*
FROM
t
;
DROP
TABLE
t
;
rmdir
$targetdir
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment