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
94fa02f4
Commit
94fa02f4
authored
Dec 14, 2018
by
Marko Mäkelä
Browse files
Options
Browse Files
Download
Plain Diff
Merge 10.1 into 10.2
parents
a2f2f686
fb252f70
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
112 additions
and
21 deletions
+112
-21
extra/mariabackup/fil_cur.cc
extra/mariabackup/fil_cur.cc
+49
-21
mysql-test/suite/mariabackup/encrypted_page_corruption.opt
mysql-test/suite/mariabackup/encrypted_page_corruption.opt
+6
-0
mysql-test/suite/mariabackup/encrypted_page_corruption.result
...l-test/suite/mariabackup/encrypted_page_corruption.result
+7
-0
mysql-test/suite/mariabackup/encrypted_page_corruption.test
mysql-test/suite/mariabackup/encrypted_page_corruption.test
+50
-0
No files found.
extra/mariabackup/fil_cur.cc
View file @
94fa02f4
...
...
@@ -30,6 +30,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
#include <trx0sys.h>
#include "fil_cur.h"
#include "fil0crypt.h"
#include "common.h"
#include "read_filt.h"
#include "xtrabackup.h"
...
...
@@ -231,7 +232,7 @@ xb_fil_cur_open(
posix_fadvise
(
cursor
->
file
,
0
,
0
,
POSIX_FADV_SEQUENTIAL
);
const
page_size_t
page_size
(
cursor
->
node
->
space
->
flags
);
const
page_size_t
page_size
(
node
->
space
->
flags
);
cursor
->
page_size
=
page_size
;
/* Allocate read buffer */
...
...
@@ -247,6 +248,19 @@ xb_fil_cur_open(
cursor
->
buf_page_no
=
0
;
cursor
->
thread_n
=
thread_n
;
if
(
!
node
->
space
->
crypt_data
&&
os_file_read
(
IORequestRead
,
node
->
handle
,
cursor
->
buf
,
0
,
page_size
.
physical
()))
{
mutex_enter
(
&
fil_system
->
mutex
);
if
(
!
node
->
space
->
crypt_data
)
{
node
->
space
->
crypt_data
=
fil_space_read_crypt_data
(
page_size
,
cursor
->
buf
);
}
mutex_exit
(
&
fil_system
->
mutex
);
}
cursor
->
space_size
=
(
ulint
)(
cursor
->
statinfo
.
st_size
/
page_size
.
physical
());
...
...
@@ -268,7 +282,6 @@ xb_fil_cur_read(
/*============*/
xb_fil_cur_t
*
cursor
)
/*!< in/out: source file cursor */
{
ibool
success
;
byte
*
page
;
ulint
i
;
ulint
npages
;
...
...
@@ -276,6 +289,8 @@ xb_fil_cur_read(
xb_fil_cur_result_t
ret
;
ib_int64_t
offset
;
ib_int64_t
to_read
;
byte
tmp_frame
[
UNIV_PAGE_SIZE_MAX
];
byte
tmp_page
[
UNIV_PAGE_SIZE_MAX
];
const
ulint
page_size
=
cursor
->
page_size
.
physical
();
xb_ad
(
!
cursor
->
is_system
()
||
page_size
==
UNIV_PAGE_SIZE
);
...
...
@@ -318,6 +333,12 @@ xb_fil_cur_read(
retry_count
=
10
;
ret
=
XB_FIL_CUR_SUCCESS
;
fil_space_t
*
space
=
fil_space_acquire_for_io
(
cursor
->
space_id
);
if
(
!
space
)
{
return
XB_FIL_CUR_ERROR
;
}
read_retry:
xtrabackup_io_throttling
();
...
...
@@ -326,19 +347,11 @@ xb_fil_cur_read(
cursor
->
buf_offset
=
offset
;
cursor
->
buf_page_no
=
(
ulint
)(
offset
/
cursor
->
page_size
.
physical
());
FilSpace
space
(
cursor
->
space_id
);
if
(
!
space
())
{
return
(
XB_FIL_CUR_ERROR
);
}
success
=
os_file_read
(
IORequestRead
,
cursor
->
file
,
cursor
->
buf
,
offset
,
(
ulint
)
to_read
);
if
(
!
success
)
{
return
(
XB_FIL_CUR_ERROR
);
if
(
!
os_file_read
(
IORequestRead
,
cursor
->
file
,
cursor
->
buf
,
offset
,
(
ulint
)
to_read
))
{
ret
=
XB_FIL_CUR_ERROR
;
goto
func_exit
;
}
/* check pages for corruption and re-read if necessary. i.e. in case of
partially written pages */
for
(
page
=
cursor
->
buf
,
i
=
0
;
i
<
npages
;
...
...
@@ -349,11 +362,26 @@ xb_fil_cur_read(
page_no
>=
FSP_EXTENT_SIZE
&&
page_no
<
FSP_EXTENT_SIZE
*
3
)
{
/* We ignore the doublewrite buffer pages */
}
else
if
(
!
fil_space_verify_crypt_checksum
(
page
,
cursor
->
page_size
,
space
->
id
,
page_no
)
&&
buf_page_is_corrupted
(
true
,
page
,
cursor
->
page_size
,
space
))
{
}
else
if
(
fil_space_verify_crypt_checksum
(
page
,
cursor
->
page_size
,
space
->
id
,
page_no
))
{
ut_ad
(
mach_read_from_4
(
page
+
FIL_PAGE_SPACE_ID
)
==
space
->
id
);
bool
decrypted
=
false
;
memcpy
(
tmp_page
,
page
,
page_size
);
if
(
!
fil_space_decrypt
(
space
,
tmp_frame
,
tmp_page
,
&
decrypted
)
||
buf_page_is_corrupted
(
true
,
tmp_page
,
cursor
->
page_size
,
space
))
{
goto
corrupted
;
}
}
else
if
(
buf_page_is_corrupted
(
true
,
page
,
cursor
->
page_size
,
space
))
{
corrupted:
retry_count
--
;
if
(
retry_count
==
0
)
{
msg
(
"[%02u] mariabackup: "
...
...
@@ -373,7 +401,6 @@ xb_fil_cur_read(
}
os_thread_sleep
(
100000
);
goto
read_retry
;
}
cursor
->
buf_read
+=
page_size
;
...
...
@@ -381,7 +408,8 @@ xb_fil_cur_read(
}
posix_fadvise
(
cursor
->
file
,
offset
,
to_read
,
POSIX_FADV_DONTNEED
);
func_exit:
fil_space_release_for_io
(
space
);
return
(
ret
);
}
...
...
mysql-test/suite/mariabackup/encrypted_page_corruption.opt
0 → 100644
View file @
94fa02f4
--innodb-encrypt-log=ON
--plugin-load-add=$FILE_KEY_MANAGEMENT_SO
--loose-file-key-management
--loose-file-key-management-filekey=FILE:$MTR_SUITE_DIR/filekeys-data.key
--loose-file-key-management-filename=$MTR_SUITE_DIR/filekeys-data.enc
--loose-file-key-management-encryption-algorithm=aes_cbc
mysql-test/suite/mariabackup/encrypted_page_corruption.result
0 → 100644
View file @
94fa02f4
call mtr.add_suppression("\\[ERROR\\] InnoDB: The page .* in file .* cannot be decrypted.");
CREATE TABLE t1(c VARCHAR(128)) ENGINE INNODB, encrypted=yes;
insert into t1 select repeat('a',100);
# Corrupt the table
# xtrabackup backup
FOUND 1 /Database page corruption detected/ in backup.log
drop table t1;
mysql-test/suite/mariabackup/encrypted_page_corruption.test
0 → 100644
View file @
94fa02f4
--
source
include
/
have_file_key_management
.
inc
call
mtr
.
add_suppression
(
"
\\
[ERROR
\\
] InnoDB: The page .* in file .* cannot be decrypted."
);
CREATE
TABLE
t1
(
c
VARCHAR
(
128
))
ENGINE
INNODB
,
encrypted
=
yes
;
insert
into
t1
select
repeat
(
'a'
,
100
);
let
$MYSQLD_DATADIR
=
`select @@datadir`
;
let
t1_IBD
=
$MYSQLD_DATADIR
/
test
/
t1
.
ibd
;
--
source
include
/
shutdown_mysqld
.
inc
--
echo
# Corrupt the table
perl
;
use
strict
;
use
warnings
;
use
Fcntl
qw(:DEFAULT :seek)
;
my
$ibd_file
=
$ENV
{
't1_IBD'
};
my
$chunk
;
my
$len
;
sysopen
IBD_FILE
,
$ibd_file
,
O_RDWR
||
die
"Unable to open
$ibd_file
"
;
sysseek
IBD_FILE
,
16384
*
3
,
SEEK_CUR
;
$chunk
=
'\xAA\xAA\xAA\xAA'
;
syswrite
IBD_FILE
,
$chunk
,
4
;
close
IBD_FILE
;
EOF
--
source
include
/
start_mysqld
.
inc
echo
# xtrabackup backup;
let
$targetdir
=
$MYSQLTEST_VARDIR
/
tmp
/
backup
;
let
$backuplog
=
$MYSQLTEST_VARDIR
/
tmp
/
backup
.
log
;
--
disable_result_log
--
error
1
exec
$XTRABACKUP
--
defaults
-
file
=
$MYSQLTEST_VARDIR
/
my
.
cnf
--
backup
--
target
-
dir
=
$targetdir
>
$backuplog
;
--
enable_result_log
--
let
SEARCH_PATTERN
=
Database
page
corruption
detected
--
let
SEARCH_FILE
=
$backuplog
--
source
include
/
search_pattern_in_file
.
inc
remove_file
$backuplog
;
drop
table
t1
;
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