Commit graph

2169 commits

Author SHA1 Message Date
Marko Mäkelä
78829a5780 Merge 10.3 into 10.4 2019-01-24 22:42:35 +02:00
Marko Mäkelä
947b6b849d Merge 10.2 into 10.3 2019-01-24 16:14:12 +02:00
Vladislav Vaintroub
5c159c9037 MDEV-18356 Renamed backup-encrypted option introduced in 7158edcba3
Rename it because it caused parser warning whenever --backup was used.
2019-01-23 12:09:02 +00:00
Brave Galera Crew
36a2a185fe Galera4 2019-01-23 15:30:00 +04:00
Marko Mäkelä
9dc81d2a7a Merge 10.3 into 10.4 2019-01-17 13:21:27 +02:00
Marko Mäkelä
77cbaa96ad Merge 10.2 into 10.3 2019-01-17 12:38:46 +02:00
Vladislav Vaintroub
2153aaf66e mariabackup : use die() macro for fatal exit with error message. 2019-01-16 08:39:49 +01:00
Vladislav Vaintroub
a8a27e65a8 MDEV-18212 mariabackup: Make output format uniform whenever possible 2019-01-15 14:15:04 +01:00
Marko Mäkelä
55a0c3eb6d Merge 10.3 into 10.4 2019-01-15 12:30:29 +02:00
Vladislav Vaintroub
32bb579192 replace hardcoded string "#sql" with tmp_file_prefix 2019-01-14 14:43:24 +01:00
Vladislav Vaintroub
24bc8edcc5 MDEV-18184 Do not copy temporary files (prefixed with #sql-) to backup 2019-01-14 14:25:08 +01:00
Marko Mäkelä
efb510462e Merge 10.2 into 10.3 2019-01-14 14:55:50 +02:00
Marko Mäkelä
248dc12e60 Merge 10.1 into 10.2 2019-01-14 11:37:51 +02:00
FaramosCZ
7372fe4da1 xb_process_datadir(): Fix resource leaks
Closes #983, #984
2019-01-14 11:02:04 +02:00
Vladislav Vaintroub
7331c661db MDEV-18201 : mariabackup- fix processing of rename/create sequence in prepare
Fix one more bug in "DDL redo" phase in prepare
If table was renamed, and then new table was created with the old name,
prepare can be confused, and .ibd can end up with wrong name.

Fix the order of how DDL fixup is applied , once again - ".new" files
should be processed after renames.
2019-01-10 19:35:45 +01:00
Vladislav Vaintroub
4a872ae1e7 MDEV-18185 - mariabackup - fix specific case of table rename handing in prepare.
If, during backup
1) Innodb table is dropped (after being copied to backup) and then
2) Before backup finished, another Innodb table is renamed, and new name
is the name of the dropped table in 1)

then, --prepare fails with assertion, as DDL fixup code in prepare
did not handle this specific case.

The fix is to process drops before renames, in prepare DDL-"redo" phase.
2019-01-09 22:28:31 +01:00
Marko Mäkelä
734510a44d Merge 10.3 into 10.4 2019-01-06 17:43:02 +02:00
Marko Mäkelä
dd43c85c48 Merge 10.2 into 10.3 2019-01-04 02:06:41 +02:00
Marko Mäkelä
23e4446adc Fix a merge error in the parent commit
Fix an inadvertently inverted condition that caused
galera.galera_sst_mariabackup_table_options test failure.
2019-01-04 01:59:46 +02:00
Marko Mäkelä
94e22efb79 Merge 10.2 into 10.3 2019-01-03 17:26:50 +02:00
Marko Mäkelä
b7392d142a Merge 10.1 into 10.2 2019-01-03 16:58:05 +02:00
Marko Mäkelä
7158edcba3 MDEV-18129 Backup fails for encrypted tables: mariabackup: Database page corruption detected at page 1
If an encrypted table is created during backup, then
mariabackup --backup could wrongly fail.

This caused a failure of the test mariabackup.huge_lsn once on buildbot.

This is due to the way how InnoDB creates .ibd files. It would first
write a dummy page 0 with no encryption information. Due to this,
xb_fil_cur_open() could wrongly interpret that the table is not encrypted.
Subsequently, page_is_corrupted() would compare the computed page
checksum to the wrong checksum. (There are both "before" and "after"
checksums for encrypted pages.)

To work around this problem, we introduce a Boolean option
--backup-encrypted that is enabled by default. With this option,
Mariabackup will assume that a nonzero key_version implies that the
page is encrypted. We need this option in order to be able to copy
encrypted tables from MariaDB 10.1 or 10.2, because unencrypted pages
that were originally created before MySQL 5.1.48 could contain nonzero
garbage in the fields that were repurposed for encryption.

Later, MDEV-18128 would clean up the way how .ibd files are created,
to remove the need for this option.

page_is_corrupted(): Add missing const qualifiers, and do not check
space->crypt_data unless --skip-backup-encrypted has been specified.

xb_fil_cur_read(): After a failed page read, output a page dump.
2019-01-03 16:46:38 +02:00
Sergei Golubchik
6bb11efa4a Merge branch '10.2' into 10.3 2019-01-03 13:09:41 +01:00
Marko Mäkelä
cf9070a8f7 Merge 10.1 into 10.2 2018-12-29 23:12:25 +02:00
Marko Mäkelä
50c9469be8 MDEV-18105 Mariabackup fails to copy encrypted InnoDB system tablespace if LSN>4G
This is a regression caused by
commit 8c43f96388
that was part of the MDEV-12112 fixes.

page_is_corrupted(): Never interpret page_no=0 as encrypted.
2018-12-29 22:59:20 +02:00
Marko Mäkelä
0b73b96f9d Merge 10.1 into 10.2 2018-12-29 11:05:26 +02:00
Vladislav Vaintroub
ed66acb291 Silence LeakSanitizer by default in mariabackup, so that phanthom "leaks"
would not hide more interesting information, like invalid memory accesses.


some "leaks" are expected
- partly this is due to weird options parsing, that runs twice, and
does not free memory after the first run.
- also we do not mind to exit()  whenever it makes sense, without full
cleanup.
2018-12-29 02:06:19 +01:00
Marko Mäkelä
cb2f36d3ea MDEV-14975: Cleanup check_all_privileges()
Remove an unused variable, and propagate the error to the caller
instead of calling exit().
2018-12-28 15:33:34 +02:00
Vladislav Vaintroub
773479f5b3 Add test for partial backup for partitioned table. 2018-12-21 16:04:16 +01:00
Marko Mäkelä
b7a9563b21 Merge 10.1 into 10.2 2018-12-21 09:43:35 +02:00
Vladislav Vaintroub
9f4a4cb401 Cleanup recent mariabackup validation patches.
- Refactor code to isolate page validation in page_is_corrupted() function.

- Introduce --extended-validation parameter(default OFF) for mariabackup
--backup to enable decryption of encrypted uncompressed pages during
backup.

- mariabackup would still always check checksum on encrypted data,
it is needed to detect  partially written pages.
2018-12-20 14:31:18 +01:00
Marko Mäkelä
610e4034d7 Merge 10.1 into 10.2 2018-12-19 15:55:55 +02:00
Marko Mäkelä
dd72d7d561 MDEV-18025: Improve test case and consistency checks
Write a test case that computes valid crc32 checksums for
an encrypted page, but zeroes out the payload area, so
that the checksum after decryption fails.

xb_fil_cur_read(): Validate the page number before trying
any checksum calculation or decrypting or decompression.
Also, skip zero-filled pages. For page_compressed pages,
ensure that the FIL_PAGE_TYPE was changed. Also, reject
FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED if no decryption was attempted.
2018-12-19 15:45:35 +02:00
Vladislav Vaintroub
74659e55b7 MDEV-16268 : sporadic checksum mismatch when opening system tablespace in backup
Attempt to fix by retrying srv_sys_space.open_or_create() if it reports
corruption.
2018-12-18 17:33:42 +01:00
Marko Mäkelä
560df47926 Merge 10.1 into 10.2 2018-12-18 16:28:19 +02:00
Thirunarayanan Balathandayuthapani
171271edf8 MDEV-18025 Mariabackup fails to detect corrupted page_compressed=1 tables
Problem:
=======
Mariabackup seems to fail to verify the pages of compressed tables.
The reason is that both fil_space_verify_crypt_checksum() and
buf_page_is_corrupted() will skip the validation for compressed pages.

Fix:
====
Mariabackup should call fil_page_decompress() for compressed and encrypted
compressed page. After that, call buf_page_is_corrupted() to
check the page corruption.
2018-12-18 18:07:17 +05:30
Marko Mäkelä
b5763ecd01 Merge 10.3 into 10.4 2018-12-18 11:33:53 +02:00
Marko Mäkelä
45531949ae Merge 10.2 into 10.3 2018-12-18 09:15:41 +02:00
Marko Mäkelä
7d245083a4 Merge 10.1 into 10.2 2018-12-17 20:15:38 +02:00
Marko Mäkelä
8c43f96388 Follow-up to MDEV-12112: corruption in encrypted table may be overlooked
The initial fix only covered a part of Mariabackup.
This fix hardens InnoDB and XtraDB in a similar way, in order
to reduce the probability of mistaking a corrupted encrypted page
for a valid unencrypted one.

This is based on work by Thirunarayanan Balathandayuthapani.

fil_space_verify_crypt_checksum(): Assert that key_version!=0.
Let the callers guarantee that. Now that we have this assertion,
we also know that buf_page_is_zeroes() cannot hold.
Also, remove all diagnostic output and related parameters,
and let the relevant callers emit such messages.
Last but not least, validate the post-encryption checksum
according to the innodb_checksum_algorithm (only accepting
one checksum for the strict variants), and no longer
try to validate the page as if it was unencrypted.

buf_page_is_zeroes(): Move to the compilation unit of the only callers,
and declare static.

xb_fil_cur_read(), buf_page_check_corrupt(): Add a condition before
calling fil_space_verify_crypt_checksum(). This is a non-functional
change.

buf_dblwr_process(): Validate the page only as encrypted or unencrypted,
but not both.
2018-12-17 19:33:44 +02:00
Vladislav Vaintroub
0a2edddbf4 MDEV-14975 : fix last commit's typo. 2018-12-15 00:06:00 +01:00
Vladislav Vaintroub
5716c71c54 MDEV-14975 mariabackup starts with unprivileged user.
ported privilege checking from xtrabackup.
Now, mariabackup would terminate early if either RELOAD or PROCESS privilege
is not held, not at the very end of backup

The behavior can be disabled with nre setting --check-privileges=0.
Also , --no-lock does not need all of these privileges, since it skips
FTWRL and SHOW ENGINE STATUS INNODB.
2018-12-14 23:36:21 +01:00
Marko Mäkelä
fd37344feb Merge 10.3 into 10.4 2018-12-14 16:20:17 +02:00
Marko Mäkelä
5fefcb0a21 Merge 10.2 into 10.3 2018-12-14 16:15:59 +02:00
Marko Mäkelä
94fa02f4d0 Merge 10.1 into 10.2 2018-12-14 16:11:05 +02:00
Marko Mäkelä
fb252f70c1 MDEV-12112 corruption in encrypted table may be overlooked
After validating the post-encryption checksum on an encrypted page,
Mariabackup should decrypt the page and validate the pre-encryption
checksum as well. This should reduce the probability of accepting
invalid pages as valid ones.

This is a backport and refactoring of a patch that was
originally written by Thirunarayanan Balathandayuthapani
for the 10.2 branch.
2018-12-14 15:44:51 +02:00
Marko Mäkelä
cfe8386296 Merge 10.2 into 10.3 2018-12-14 14:05:25 +02:00
Marko Mäkelä
dbb39a778d MDEV-17958: Make innochecksum follow the build option
Innochecksum was being built as if WITH_INNODB_BUG_ENDIAN_CRC32:BOOL=OFF
had been specified.

Also, clean up tests:

innodb.innochecksum: Useless; superceded by innodb_zip.innochecksum.
innodb.innodb_zip_innochecksum: Remove; duplicated innodb_zip.innochecksum.
innodb.innodb_zip_innochecksum2: Remove; duplicated innodb_zip.innochecksum_2.
innodb.innodb_zip_innochecksum3: Remove; duplicated innodb_zip.innochecksum_3.

No test case was added. I tested manually by adding debug instrumentation
to both innochecksum and buf_page_is_checksum_valid_crc32() to make
innochecksum write the buggy crc32, and to get warnings for falling back
to the buggy checksum. Automating this would require that tests be
adjusted depending on the build options.
2018-12-14 13:52:13 +02:00
Aleksey Midenkov
330c6218dd Replace dict_instant_t::non_pk_col_map with field_map 2018-12-13 22:23:49 +02:00
Vladislav Vaintroub
3efed7533c Fix lock_ddl_per_table handling in mariabackup.
mariabackup.lock_ddl_per_table was broken, after MDEV-17772 got fixed.
Fix removes MDL waiter killer, it is is not needed anymore.
2018-12-10 14:03:52 +01:00