Commit fef959a6 authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul

Changing the size calculation broke brt-test. Changed it so if cachetable...

Changing the size calculation broke brt-test.  Changed it so if cachetable overflows its budget, then the cachetable continues to work. Addresses #669.

git-svn-id: file:///svn/tokudb@3338 c7de825b-a66e-492c-adef-691d508d4ae1
parent 2d892e59
......@@ -164,13 +164,13 @@ static void test_multiple_dbs (void) {
static void test_multiple_dbs_many (void) {
enum { MANYN = 16 };
int i, r;
const char *name = "test.brt";
const char *name = "test_mdbm.brt";
CACHETABLE ct;
BRT trees[MANYN];
if (verbose) printf("test_multiple_dbs_many:\n");
toku_memory_check_all_free();
unlink(name);
r = toku_brt_create_cachetable(&ct, MANYN+4, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = toku_brt_create_cachetable(&ct, (MANYN+4), ZERO_LSN, NULL_LOGGER); assert(r==0);
for (i=0; i<MANYN; i++) {
char dbname[20];
snprintf(dbname, 20, "db%d", i);
......
......@@ -1890,16 +1890,16 @@ int toku_brt_open(BRT t, const char *fname, const char *fname_in_env, const char
t->db = db;
{
int fd = open(fname, O_RDWR, 0777);
r = errno;
if (fd==-1) {
r = errno;
if (errno==ENOENT) {
if (!is_create) {
t->database_name=0;
goto died0a;
}
fd = open(fname, O_RDWR | O_CREAT, 0777);
r = errno;
if (fd==-1) {
r = errno;
t->database_name=0;
goto died0a;
}
......
......@@ -345,7 +345,7 @@ static int maybe_flush_some (CACHETABLE t, long size __attribute__((unused))) {
}
/* All were pinned. */
//printf("All are pinned\n");
r = 1;
return 0; // Don't indicate an error code. Instead let memory get overfull.
}
if (4 * t->n_in_table < t->table_size)
......@@ -400,10 +400,10 @@ int toku_cachetable_put(CACHEFILE cachefile, CACHEKEY key, void*value, long size
}
}
}
if (maybe_flush_some(cachefile->cachetable, size))
return -2;
int r;
if ((r=maybe_flush_some(cachefile->cachetable, size))) return r;
// flushing could change the result from hashit()
int r = cachetable_insert_at(cachefile, hashit(cachefile->cachetable, key), key, value, size, flush_callback, fetch_callback, extraargs, 1, ZERO_LSN);
r = cachetable_insert_at(cachefile, hashit(cachefile->cachetable, key), key, value, size, flush_callback, fetch_callback, extraargs, 1, ZERO_LSN);
return r;
}
......@@ -422,12 +422,12 @@ int toku_cachetable_get_and_pin(CACHEFILE cachefile, CACHEKEY key, void**value,
return 0;
}
}
if (maybe_flush_some(t, 1)) return -2;
int r;
if ((r=maybe_flush_some(t, 1))) return r;
// Note. hashit(t,key) may have changed as a result of flushing.
{
void *toku_value;
long size = 1; // compat
int r;
LSN written_lsn;
WHEN_TRACE_CT(printf("%s:%d CT: fetch_callback(%lld...)\n", __FILE__, __LINE__, key));
if ((r=fetch_callback(cachefile, key, &toku_value, &size, extraargs, &written_lsn))) {
......
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