mirror of
https://github.com/MariaDB/server.git
synced 2025-02-02 03:51:50 +01:00
[t:2499] Induce ENOSPC return from toku_os_write().
git-svn-id: file:///svn/toku/tokudb@20221 c7de825b-a66e-492c-adef-691d508d4ae1
This commit is contained in:
parent
061de97e14
commit
eaa5564cbd
1 changed files with 29 additions and 34 deletions
|
@ -5,8 +5,7 @@
|
||||||
|
|
||||||
/* TODO:
|
/* TODO:
|
||||||
*
|
*
|
||||||
* When loader is fixed to not crash on failed call to toku_os_write(),
|
* When ready, add simulated errors on calls to pwrite() and malloc()
|
||||||
* get rid of INDUCE_BAD_WRITE and -e argument.
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -65,7 +64,6 @@ int NUM_ROWS=100000;
|
||||||
//static int NUM_ROWS=50000000;
|
//static int NUM_ROWS=50000000;
|
||||||
int CHECK_RESULTS=0;
|
int CHECK_RESULTS=0;
|
||||||
int USE_PUTS=0;
|
int USE_PUTS=0;
|
||||||
int INDUCE_BAD_WRITE=0;
|
|
||||||
int assert_temp_files = 0;
|
int assert_temp_files = 0;
|
||||||
enum {MAGIC=311};
|
enum {MAGIC=311};
|
||||||
|
|
||||||
|
@ -568,20 +566,22 @@ static void run_test(enum test_type t, int trigger)
|
||||||
|
|
||||||
generate_permute_tables();
|
generate_permute_tables();
|
||||||
|
|
||||||
|
write_count_trigger = 0;
|
||||||
|
fwrite_count_trigger = 0;
|
||||||
fwrite_count = fwrite_enospc = 0;
|
fwrite_count = fwrite_enospc = 0;
|
||||||
write_count = write_enospc = 0;
|
write_count = write_enospc = 0;
|
||||||
if (t == enospc_f)
|
if (t == enospc_f) {
|
||||||
fwrite_count_trigger = trigger;
|
fwrite_count_trigger = trigger;
|
||||||
else
|
}
|
||||||
fwrite_count_trigger = 0;
|
else if (t == enospc_w) {
|
||||||
if (t == enospc_w)
|
|
||||||
write_count_trigger = trigger;
|
write_count_trigger = trigger;
|
||||||
else
|
}
|
||||||
write_count_trigger = 0;
|
|
||||||
|
|
||||||
db_env_set_func_loader_fwrite(bad_fwrite);
|
db_env_set_func_loader_fwrite(bad_fwrite);
|
||||||
db_env_set_func_write(bad_write);
|
db_env_set_func_write(bad_write);
|
||||||
|
|
||||||
|
if (t == enospc_w && trigger == 1)
|
||||||
|
printf("Inducing enospc on first call to toku_os_write()\n");
|
||||||
test_loader(t, dbs);
|
test_loader(t, dbs);
|
||||||
|
|
||||||
for(int i=0;i<NUM_DBS;i++) {
|
for(int i=0;i<NUM_DBS;i++) {
|
||||||
|
@ -611,34 +611,32 @@ static void run_all_tests(void) {
|
||||||
if (verbose) printf("\n\nTesting loader with loader close and txn abort\n");
|
if (verbose) printf("\n\nTesting loader with loader close and txn abort\n");
|
||||||
run_test(abort_txn, 0);
|
run_test(abort_txn, 0);
|
||||||
|
|
||||||
if (INDUCE_BAD_WRITE) {
|
enum test_type t[2] = {enospc_f, enospc_w};
|
||||||
int i;
|
char * write_type[2] = {"fwrite", "write"};
|
||||||
for (i = 1; i < 5; i++) {
|
int * nomp[2] = {&fwrite_count_nominal, &write_count_nominal};
|
||||||
trigger = write_count_nominal / i;
|
int j;
|
||||||
if (verbose) printf("\n\nTesting loader with enospc induced at write count %d\n", trigger);
|
for (j = 0; j<2; j++) {
|
||||||
run_test(enospc_w, trigger);
|
int nominal = *(nomp[j]);
|
||||||
}
|
printf("\nNow test with induced ENOSPC errors returned from %s, nominal = %d\n", write_type[j], nominal);
|
||||||
}
|
|
||||||
{
|
|
||||||
int i;
|
int i;
|
||||||
// induce write error at beginning of process
|
// induce write error at beginning of process
|
||||||
for (i = 1; i < 5 * NUM_DBS && i < fwrite_count_nominal; i++) {
|
for (i = 1; i < 5 * NUM_DBS && i < nominal; i++) {
|
||||||
trigger = i;
|
trigger = i;
|
||||||
if (verbose) printf("\n\nTesting loader with enospc induced at fwrite count %d\n", trigger);
|
if (verbose) printf("\n\nTesting loader with enospc induced at %s count %d\n", write_type[j], trigger);
|
||||||
run_test(enospc_f, trigger);
|
run_test(t[j], trigger);
|
||||||
}
|
}
|
||||||
// induce write error sprinkled through process
|
// induce write error sprinkled through process
|
||||||
for (i = 2; i < 5 && i < fwrite_count_nominal; i++) {
|
for (i = 2; i < 5 && i < nominal; i++) {
|
||||||
trigger = fwrite_count_nominal / i;
|
trigger = nominal / i;
|
||||||
if (verbose) printf("\n\nTesting loader with enospc induced at fwrite count %d\n", trigger);
|
if (verbose) printf("\n\nTesting loader with enospc induced at %s count %d\n", write_type[j], trigger);
|
||||||
run_test(enospc_f, trigger);
|
run_test(t[j], trigger);
|
||||||
}
|
}
|
||||||
// induce write error at end of process
|
// induce write error at end of process
|
||||||
for (i = 0; i < 5 * NUM_DBS && i < fwrite_count_nominal; i++) {
|
for (i = 0; i < 5 * NUM_DBS && i < nominal; i++) {
|
||||||
trigger = fwrite_count_nominal - i;
|
trigger = nominal - i;
|
||||||
assert(trigger > 0);
|
assert(trigger > 0);
|
||||||
if (verbose) printf("\n\nTesting loader with enospc induced at fwrite count %d\n", trigger);
|
if (verbose) printf("\n\nTesting loader with enospc induced at %s count %d\n", write_type[j], trigger);
|
||||||
run_test(enospc_f, trigger);
|
run_test(t[j], trigger);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -671,7 +669,7 @@ static void do_args(int argc, char * const argv[]) {
|
||||||
} else if (strcmp(argv[0], "-h")==0) {
|
} else if (strcmp(argv[0], "-h")==0) {
|
||||||
resultcode=0;
|
resultcode=0;
|
||||||
do_usage:
|
do_usage:
|
||||||
fprintf(stderr, "Usage: -h -c -d <num_dbs> -r <num_rows>\n%s\n", cmd);
|
fprintf(stderr, "Usage: -h -c -s -p -d <num_dbs> -r <num_rows>\n%s\n", cmd);
|
||||||
exit(resultcode);
|
exit(resultcode);
|
||||||
} else if (strcmp(argv[0], "-d")==0) {
|
} else if (strcmp(argv[0], "-d")==0) {
|
||||||
argc--; argv++;
|
argc--; argv++;
|
||||||
|
@ -689,9 +687,6 @@ static void do_args(int argc, char * const argv[]) {
|
||||||
} else if (strcmp(argv[0], "-p")==0) {
|
} else if (strcmp(argv[0], "-p")==0) {
|
||||||
USE_PUTS = LOADER_USE_PUTS;
|
USE_PUTS = LOADER_USE_PUTS;
|
||||||
printf("Using puts\n");
|
printf("Using puts\n");
|
||||||
} else if (strcmp(argv[0], "-e")==0) {
|
|
||||||
INDUCE_BAD_WRITE = 1;
|
|
||||||
printf("Using enospc return from toku_os_write()\n");
|
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "Unknown arg: %s\n", argv[0]);
|
fprintf(stderr, "Unknown arg: %s\n", argv[0]);
|
||||||
resultcode=1;
|
resultcode=1;
|
||||||
|
|
Loading…
Add table
Reference in a new issue