mirror of
https://github.com/MariaDB/server.git
synced 2025-01-22 23:04:20 +01:00
Implement DB_ENV->log_flush. Fixes #393.
git-svn-id: file:///svn/tokudb@2610 c7de825b-a66e-492c-adef-691d508d4ae1
This commit is contained in:
parent
13b9c110ed
commit
3d86a14982
2 changed files with 69 additions and 4 deletions
66
src/tests/test_logflush.c
Normal file
66
src/tests/test_logflush.c
Normal file
|
@ -0,0 +1,66 @@
|
|||
/* -*- mode: C; c-basic-offset: 4 -*- */
|
||||
#ident "Copyright (c) 2007 Tokutek Inc. All rights reserved."
|
||||
|
||||
#include <db.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/mman.h>
|
||||
#include "test.h"
|
||||
|
||||
// Return the offset
|
||||
int grep_for_in_logs(const char *str) {
|
||||
#ifdef TOKUDB
|
||||
#define lname DIR "//log000000000000.tokulog"
|
||||
#else
|
||||
#define lname DIR "//log.0000000001"
|
||||
#endif
|
||||
int fd = open(lname, O_RDONLY);
|
||||
assert(fd>=0);
|
||||
struct stat statbuf;
|
||||
int r = fstat(fd, &statbuf);
|
||||
assert(r==0);
|
||||
void *addr_v = mmap(0, statbuf.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
|
||||
assert(addr_v!=MAP_FAILED);
|
||||
char *fstr = addr_v;
|
||||
int searchlen=strlen(str);
|
||||
int i;
|
||||
for (i=0; i+searchlen<statbuf.st_size; i++) {
|
||||
if (memcmp(str, fstr+i, searchlen)==0) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int main (int argc, char *argv[]) {
|
||||
int r;
|
||||
DB_ENV *env;
|
||||
DB *db;
|
||||
DB_TXN *tid;
|
||||
|
||||
system("rm -rf " DIR);
|
||||
r=mkdir(DIR, 0777); assert(r==0);
|
||||
r=db_env_create(&env, 0); assert(r==0);
|
||||
r=env->open(env, DIR, DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_CREATE|DB_PRIVATE, 0777); CKERR(r);
|
||||
r=db_create(&db, env, 0); CKERR(r);
|
||||
r=env->txn_begin(env, 0, &tid, 0); assert(r==0);
|
||||
r=db->open(db, tid, "foo.db", 0, DB_BTREE, DB_CREATE, 0777); CKERR(r);
|
||||
r=tid->commit(tid, 0); assert(r==0);
|
||||
|
||||
{
|
||||
DBT key,data;
|
||||
char hello[]="hello";
|
||||
char there[]="there";
|
||||
r=env->txn_begin(env, 0, &tid, 0); CKERR(r);
|
||||
r=db->put(db, tid,
|
||||
dbt_init(&key, hello, sizeof(hello)),
|
||||
dbt_init(&data, there, sizeof(there)),
|
||||
0);
|
||||
r=grep_for_in_logs(hello);
|
||||
assert(r==-1);
|
||||
r=env->log_flush(env, 0); CKERR(r);
|
||||
r=grep_for_in_logs(hello);
|
||||
assert(r>=0);
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -336,11 +336,10 @@ static int toku_env_log_archive(DB_ENV * env, char **list[], u_int32_t flags) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int toku_env_log_flush(DB_ENV * env, const DB_LSN * lsn) {
|
||||
static int toku_env_log_flush(DB_ENV * env, const DB_LSN * lsn __attribute__((__unused__))) {
|
||||
HANDLE_PANICKED_ENV(env);
|
||||
env=env; lsn=lsn;
|
||||
toku_ydb_barf();
|
||||
return 1;
|
||||
// We just flush everything. MySQL uses lsn==0 which means flush everything. For anyone else using the log, it is correct to flush too much, so we are OK.
|
||||
return toku_logger_fsync(env->i->logger);
|
||||
}
|
||||
|
||||
static int toku_env_set_cachesize(DB_ENV * env, u_int32_t gbytes, u_int32_t bytes, int ncache) {
|
||||
|
|
Loading…
Add table
Reference in a new issue