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

DB-883 tokudb broken after 'create database log002015' #325

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 8 additions & 3 deletions ft/logger/logger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ static void toku_print_bytes (FILE *outf, uint32_t len, char *data) {

static bool is_a_logfile_any_version (const char *name, uint64_t *number_result, uint32_t *version_of_log) {
bool rval = true;
uint64_t result;
int n;
uint64_t result = 0UL;
int n = 0;
int r;
uint32_t version;
uint32_t version = 0;
r = sscanf(name, "log%" SCNu64 ".tokulog%" SCNu32 "%n", &result, &version, &n);
if (r!=2 || name[n]!='\0' || version <= TOKU_LOG_VERSION_1) {
//Version 1 does NOT append 'version' to end of '.tokulog'
Expand Down Expand Up @@ -644,6 +644,11 @@ int toku_logger_find_logfiles (const char *directory, char ***resultp, int *n_lo
while ((de=readdir(d))) {
uint64_t thisl;
uint32_t version_ignore;

// if de is directory, skip it
if (de->d_type == DT_DIR)
continue;

if ( !(is_a_logfile_any_version(de->d_name, &thisl, &version_ignore)) ) continue; //#2424: Skip over files that don't match the exact logfile template
if (n_results+1>=result_limit) {
result_limit*=2;
Expand Down
87 changes: 87 additions & 0 deletions ft/tests/recovery-find-redo-logs.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4:
#ident "$Id$"
/*======
This file is part of PerconaFT.


Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved.

PerconaFT is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2,
as published by the Free Software Foundation.

PerconaFT 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 PerconaFT. If not, see <http://www.gnu.org/licenses/>.

----------------------------------------

PerconaFT is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License, version 3,
as published by the Free Software Foundation.

PerconaFT 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 Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with PerconaFT. If not, see <http://www.gnu.org/licenses/>.
======= */

#ident "Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved."

// Test that find redo-log files works correctly.

#include "test.h"
#include <libgen.h>

static int
run_test(void) {
int r;

// setup the test dir
toku_os_recursive_delete(TOKU_TEST_FILENAME);
r = toku_os_mkdir(TOKU_TEST_FILENAME, S_IRWXU);
assert(r == 0);

char testdir[TOKU_PATH_MAX+1];
char testfile[TOKU_PATH_MAX+1];

toku_path_join(testdir, 2, TOKU_TEST_FILENAME, "log002015");
r = toku_os_mkdir(testdir, S_IRWXU);
assert(r == 0);

toku_path_join(testfile, 2, TOKU_TEST_FILENAME, "log002015.tokulog27");
int fd = open(testfile, O_CREAT+O_WRONLY+O_TRUNC+O_EXCL+O_BINARY, S_IRWXU);
assert(fd != -1);
close(fd);

char **logfiles = nullptr;
int n_logfiles = 0;
r = toku_logger_find_logfiles(TOKU_TEST_FILENAME, &logfiles, &n_logfiles);
CKERR(r);
assert(n_logfiles == 1);
fprintf(stderr, "redo log nums: %d \n", n_logfiles);
for (int i; i < n_logfiles; i++) {
fprintf(stderr, "redo log %s \n", logfiles[i]);
}

toku_logger_free_logfiles(logfiles, n_logfiles);

toku_os_recursive_delete(TOKU_TEST_FILENAME);

return 0;
}

int
test_main(int UU(argc), const char *UU(argv[])) {
int r;
r = run_test();
return r;
}