Commit 0ba4119b authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul Committed by Yoni Fogel

[t:4367] Make drd work on diskfull. Net result: couldn't find any bad races. Refs #4367.

git-svn-id: file:///svn/toku/tokudb@38622 c7de825b-a66e-492c-adef-691d508d4ae1
parent a1865e48
......@@ -566,15 +566,15 @@ void toku_brtnode_flush_callback (CACHEFILE cachefile, int fd, BLOCKNUM nodename
update_header_stats(&(h->checkpoint_staging_stats), &deltas);
}
if (for_checkpoint)
brt_status.disk_flush_leaf_for_checkpoint++;
__sync_fetch_and_add(&brt_status.disk_flush_leaf_for_checkpoint, 1);
else
brt_status.disk_flush_leaf++;
__sync_fetch_and_add(&brt_status.disk_flush_leaf, 1);
}
else {
if (for_checkpoint)
brt_status.disk_flush_nonleaf_for_checkpoint++;
__sync_fetch_and_add(&brt_status.disk_flush_nonleaf_for_checkpoint, 1);
else
brt_status.disk_flush_nonleaf++;
__sync_fetch_and_add(&brt_status.disk_flush_nonleaf, 1);
}
}
//printf("%s:%d %p->mdict[0]=%p\n", __FILE__, __LINE__, brtnode, brtnode->mdicts[0]);
......
......@@ -9,6 +9,7 @@
#include <string.h>
#include <time.h>
#include <stdarg.h>
#include <valgrind/drd.h>
#include "memory.h"
#include "workqueue.h"
......@@ -410,6 +411,12 @@ int toku_create_cachetable(CACHETABLE *result, long size_limit, LSN UU(initial_l
CACHETABLE MALLOC(ct);
if (ct == 0) return ENOMEM;
memset(ct, 0, sizeof(*ct));
DRD_IGNORE_VAR(ct->size_nonleaf); // modified only when the cachetable lock is held, but read by engine status
DRD_IGNORE_VAR(ct->size_current);
DRD_IGNORE_VAR(ct->size_evicting);
DRD_IGNORE_VAR(ct->size_leaf);
DRD_IGNORE_VAR(ct->size_rollback);
DRD_IGNORE_VAR(ct->size_cachepressure);
ct->table_size = 4;
rwlock_init(&ct->pending_lock);
XCALLOC_N(ct->table_size, ct->table);
......@@ -4005,3 +4012,11 @@ toku_cleaner_thread (void *cachetable_v)
return 0;
}
void __attribute__((__constructor__)) toku_cachetable_drd_ignore(void);
void
toku_cachetable_drd_ignore(void) {
// incremented only while lock is held, but read by engine status asynchronously.
DRD_IGNORE_VAR(cachetable_lock_taken);
DRD_IGNORE_VAR(cachetable_lock_released);
DRD_IGNORE_VAR(cachetable_evictions);
}
......@@ -134,15 +134,15 @@ do_db_work(void) {
}
}
static int write_count = 0;
static volatile int write_count = 0;
#define FAIL_NEVER 0x7FFFFFFF
static int fail_at = FAIL_NEVER;
static ssize_t
pwrite_counting_and_failing (int fd, const void *buf, size_t size, toku_off_t off)
{
write_count++;
if (write_count>fail_at) {
int this_count = __sync_add_and_fetch(&write_count, 1);
if (this_count>fail_at) {
if (verbose>1) { printf("Failure imminent at %d:\n", fail_at); fflush(stdout); }
errno = ENOSPC;
return -1;
......@@ -154,8 +154,8 @@ pwrite_counting_and_failing (int fd, const void *buf, size_t size, toku_off_t of
static ssize_t
write_counting_and_failing (int fd, const void *buf, size_t size)
{
write_count++;
if (write_count>fail_at) {
int this_count = __sync_add_and_fetch(&write_count, 1);
if (this_count>fail_at) {
if (verbose>1) { printf("Failure imminent at %d:\n", fail_at); fflush(stdout); }
errno = ENOSPC;
return -1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment