Skip to content

Commit

Permalink
Use standard InnoDB error mechanism on compression and encryption
Browse files Browse the repository at this point in the history
error messages.
  • Loading branch information
Jan Lindström committed Mar 2, 2015
1 parent 1f1f977 commit 7047bef
Show file tree
Hide file tree
Showing 10 changed files with 337 additions and 264 deletions.
@@ -1,4 +1,4 @@
call mtr.add_suppression("InnoDB: Warning: Compression failed for space*");
call mtr.add_suppression("Compression failed for space*");
set global innodb_file_format = `barracuda`;
set global innodb_file_per_table = on;
set global innodb_compression_algorithm = 6;
Expand Down
@@ -1,5 +1,6 @@
call mtr.add_suppression("KeyID 0 not found or with error. Check the key and the log file*");
call mtr.add_suppression("Disabling redo log encryption");
call mtr.add_suppression("KeyID 0 not found or with error. Check the key and the log*");
call mtr.add_suppression("Disabling redo log encryp*");
call mtr.add_suppression("InnoDB: Redo log crypto: Can't initialize to key version*");
SET GLOBAL innodb_file_format = `Barracuda`;
SET GLOBAL innodb_file_per_table = ON;
create table innodb_normal(c1 bigint not null, b char(200)) engine=innodb;
Expand Down
@@ -1,7 +1,7 @@
-- source include/have_innodb.inc
-- source include/have_innodb_snappy.inc

call mtr.add_suppression("InnoDB: Warning: Compression failed for space*");
call mtr.add_suppression("Compression failed for space*");

--disable_query_log
let $innodb_compression_algorithm_orig=`select @@innodb_compression_algorithm`;
Expand Down
Expand Up @@ -6,8 +6,9 @@ let $innodb_file_format_orig = `SELECT @@innodb_file_format`;
let $innodb_file_per_table_orig = `SELECT @@innodb_file_per_table`;
--enable_query_log

call mtr.add_suppression("KeyID 0 not found or with error. Check the key and the log file*");
call mtr.add_suppression("Disabling redo log encryption");
call mtr.add_suppression("KeyID 0 not found or with error. Check the key and the log*");
call mtr.add_suppression("Disabling redo log encryp*");
call mtr.add_suppression("InnoDB: Redo log crypto: Can't initialize to key version*");

SET GLOBAL innodb_file_format = `Barracuda`;
SET GLOBAL innodb_file_per_table = ON;
Expand Down
58 changes: 42 additions & 16 deletions storage/innobase/fil/fil0crypt.cc
@@ -1,3 +1,29 @@
/*****************************************************************************
Copyright (C) 2013, 2015, Google Inc. All Rights Reserved.
Copyright (C) 2014, 2015, MariaDB Corporation. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*****************************************************************************/
/**************************************************//**
@file fil0crypt.cc
Innodb file space encrypt/decrypt
Created Jonas Oreland Google
Modified Jan Lindström jan.lindstrom@mariadb.com
*******************************************************/

#include "fil0fil.h"
#include "srv0srv.h"
#include "srv0start.h"
Expand All @@ -11,6 +37,7 @@
#include "fsp0fsp.h"
#include "fil0pagecompress.h"
#include "fil0pageencryption.h"
#include "ha_prototypes.h" // IB_LOG_

#include <my_crypt.h>

Expand Down Expand Up @@ -368,11 +395,11 @@ fil_space_read_crypt_data(ulint space, const byte* page, ulint offset)
}

if (memcmp(page + offset, CRYPT_MAGIC, MAGIC_SZ) != 0) {
fprintf(stderr,
"Warning: found potentially bogus bytes on "
ib_logf(IB_LOG_LEVEL_WARN,
"Found potentially bogus bytes on "
"page 0 offset %lu for space %lu : "
"[ %.2x %.2x %.2x %.2x %.2x %.2x ]. "
"Assuming space is not encrypted!\n",
"Assuming space is not encrypted!.",
offset, space,
page[offset + 0],
page[offset + 1],
Expand All @@ -387,10 +414,10 @@ fil_space_read_crypt_data(ulint space, const byte* page, ulint offset)

if (! (type == CRYPT_SCHEME_UNENCRYPTED ||
type == CRYPT_SCHEME_1)) {
fprintf(stderr,
ib_logf(IB_LOG_LEVEL_ERROR,
"Found non sensible crypt scheme: %lu for space %lu "
" offset: %lu bytes: "
"[ %.2x %.2x %.2x %.2x %.2x %.2x ]\n",
"[ %.2x %.2x %.2x %.2x %.2x %.2x ].",
type, space, offset,
page[offset + 0 + MAGIC_SZ],
page[offset + 1 + MAGIC_SZ],
Expand All @@ -403,10 +430,10 @@ fil_space_read_crypt_data(ulint space, const byte* page, ulint offset)

ulint iv_length = mach_read_from_1(page + offset + MAGIC_SZ + 1);
if (! (iv_length == CRYPT_SCHEME_1_IV_LEN)) {
fprintf(stderr,
ib_logf(IB_LOG_LEVEL_ERROR,
"Found non sensible iv length: %lu for space %lu "
" offset: %lu type: %lu bytes: "
"[ %.2x %.2x %.2x %.2x %.2x %.2x ]\n",
"[ %.2x %.2x %.2x %.2x %.2x %.2x ].",
iv_length, space, offset, type,
page[offset + 0 + MAGIC_SZ],
page[offset + 1 + MAGIC_SZ],
Expand Down Expand Up @@ -1414,8 +1441,8 @@ fil_crypt_realloc_iops(rotate_thread_t *state)
state->sum_waited_us / state->cnt_waited;

#if DEBUG_KEYROTATION_THROTTLING
fprintf(stderr,
"thr_no: %u - update estimated_max_iops from %u to %u\n",
ib_logf(IB_LOG_LEVEL_INFO,
"thr_no: %u - update estimated_max_iops from %u to %u.",
state->thread_no,
state->estimated_max_iops,
1000000 / avg_wait_time_us);
Expand All @@ -1428,8 +1455,8 @@ fil_crypt_realloc_iops(rotate_thread_t *state)
state->sum_waited_us = 0;
} else {
#if DEBUG_KEYROTATION_THROTTLING
fprintf(stderr,
"thr_no: %u only waited %lu%% skip re-estimate\n",
ib_logf(IB_LOG_LEVEL_INFO,
"thr_no: %u only waited %lu%% skip re-estimate.",
state->thread_no,
(100 * state->cnt_waited) / state->batch);
#endif
Expand Down Expand Up @@ -1477,8 +1504,8 @@ fil_crypt_realloc_iops(rotate_thread_t *state)
n_fil_crypt_iops_allocated += extra;
state->allocated_iops += extra;
#if DEBUG_KEYROTATION_THROTTLING
fprintf(stderr,
"thr_no: %u increased iops from %u to %u\n",
ib_logf(IB_LOG_LEVEL_INFO,
"thr_no: %u increased iops from %u to %u.",
state->thread_no,
state->allocated_iops - extra,
state->allocated_iops);
Expand Down Expand Up @@ -2325,9 +2352,8 @@ fil_space_crypt_close_tablespace(

uint now = time(0);
if (now >= last + 30) {
fprintf(stderr,
"WARNING: "
"waited %u seconds to drop space: %lu\n",
ib_logf(IB_LOG_LEVEL_WARN,
"Waited %u seconds to drop space: %lu.",
now - start, space);
last = now;
}
Expand Down

0 comments on commit 7047bef

Please sign in to comment.