Commit 06a7a6a1 authored by Rich Prohaska's avatar Rich Prohaska Committed by Yoni Fogel

add the timestamp log entry. addresses #1855

git-svn-id: file:///svn/toku/tokudb@13284 c7de825b-a66e-492c-adef-691d508d4ae1
parent 83987ffa
......@@ -117,6 +117,10 @@ static inline int toku_logsizeof_u_int32_t (u_int32_t v __attribute__((__unused_
return 4;
}
static inline int toku_logsizeof_u_int64_t (u_int32_t v __attribute__((__unused__))) {
return 8;
}
static inline int toku_logsizeof_FILENUM (FILENUM v __attribute__((__unused__))) {
return 4;
}
......
......@@ -119,6 +119,9 @@ const struct logtype logtypes[] = {
{"BYTESTRING", "key", 0},
{"BYTESTRING", "data", 0},
NULLFIELD}},
{"timestamp", 'T', FA{{"u_int64_t", "timestamp", 0},
{"BYTESTRING", "comment", 0},
NULLFIELD}},
{0,0,FA{NULLFIELD}}
};
......
......@@ -459,7 +459,7 @@ static int toku_fread_int32_t (FILE *f, int32_t *v, struct x1764 *checksum, u_in
return r;
}
static int toku_fread_u_int64_t (FILE *f, u_int64_t *v, struct x1764 *checksum, u_int32_t *len) {
int toku_fread_u_int64_t (FILE *f, u_int64_t *v, struct x1764 *checksum, u_int32_t *len) {
u_int32_t v1,v2;
int r;
r=toku_fread_u_int32_t(f, &v1, checksum, len); if (r!=0) return r;
......@@ -573,7 +573,15 @@ int toku_logprint_u_int32_t (FILE *outf, FILE *inf, const char *fieldname, struc
fprintf(outf, " %s=", fieldname);
fprintf(outf, format ? format : "%d", v);
return 0;
}
int toku_logprint_u_int64_t (FILE *outf, FILE *inf, const char *fieldname, struct x1764 *checksum, u_int32_t *len, const char *format) {
u_int64_t v;
int r = toku_fread_u_int64_t(inf, &v, checksum, len);
if (r!=0) return r;
fprintf(outf, " %s=", fieldname);
fprintf(outf, format ? format : "%"PRId64, v);
return 0;
}
void toku_print_BYTESTRING (FILE *outf, u_int32_t len, char *data) {
......
......@@ -30,6 +30,7 @@ int toku_logger_log_fopen (TOKUTXN txn, const char * fname, FILENUM filenum);
int toku_fread_u_int8_t (FILE *f, u_int8_t *v, struct x1764 *mm, u_int32_t *len);
int toku_fread_u_int32_t_nocrclen (FILE *f, u_int32_t *v);
int toku_fread_u_int32_t (FILE *f, u_int32_t *v, struct x1764 *checksum, u_int32_t *len);
int toku_fread_u_int64_t (FILE *f, u_int64_t *v, struct x1764 *checksum, u_int32_t *len);
int toku_fread_LSN (FILE *f, LSN *lsn, struct x1764 *checksum, u_int32_t *len);
int toku_fread_FILENUM (FILE *f, FILENUM *filenum, struct x1764 *checksum, u_int32_t *len);
int toku_fread_DISKOFF (FILE *f, DISKOFF *diskoff, struct x1764 *checksum, u_int32_t *len);
......@@ -43,6 +44,7 @@ int toku_logprint_LSN (FILE *outf, FILE *inf, const char *fieldname, struct x176
int toku_logprint_TXNID (FILE *outf, FILE *inf, const char *fieldname, struct x1764 *checksum, u_int32_t *len, const char *format __attribute__((__unused__)));
int toku_logprint_u_int8_t (FILE *outf, FILE *inf, const char *fieldname, struct x1764 *checksum, u_int32_t *len, const char *format);
int toku_logprint_u_int32_t (FILE *outf, FILE *inf, const char *fieldname, struct x1764 *checksum, u_int32_t *len, const char *format);
int toku_logprint_u_int64_t (FILE *outf, FILE *inf, const char *fieldname, struct x1764 *checksum, u_int32_t *len, const char *format);
void toku_print_BYTESTRING (FILE *outf, u_int32_t len, char *data);
int toku_logprint_BYTESTRING (FILE *outf, FILE *inf, const char *fieldname, struct x1764 *checksum, u_int32_t *len, const char *format __attribute__((__unused__)));
int toku_logprint_FILENUM (FILE *outf, FILE *inf, const char *fieldname, struct x1764 *checksum, u_int32_t *len, const char *format);
......
......@@ -348,6 +348,16 @@ static int toku_recover_backward_xbegin (struct logtype_xbegin *l, struct backwa
abort();
}
static int toku_recover_timestamp (LSN UU(lsn), u_int64_t UU(timestamp), BYTESTRING comment) {
toku_free_BYTESTRING(comment);
return 0;
}
static int toku_recover_backward_timestamp (struct logtype_timestamp *l, struct backward_scan_state *UU(bs)) {
toku_free_BYTESTRING(l->comment);
return 0;
}
static int toku_delete_rolltmp_files (const char *log_dir) {
struct dirent *de;
DIR *d = opendir(log_dir);
......
/* -*- mode: C; c-basic-offset: 4 -*- */
#ident "Copyright (c) 2007, 2008 Tokutek Inc. All rights reserved."
#include "test.h"
#include "includes.h"
static u_int64_t now(void) {
struct timeval tv;
int r = gettimeofday(&tv, NULL);
assert(r == 0);
return tv.tv_sec * 1000000ULL + tv.tv_usec;
}
#define dname __FILE__ ".dir"
#define rmrf "rm -rf " dname "/"
// log a couple of timestamp entries and verify the log by walking
// a cursor through the log entries
int
test_main (int argc __attribute__((__unused__)),
const char *argv[] __attribute__((__unused__))) {
int r;
system(rmrf);
r = toku_os_mkdir(dname, S_IRWXU); assert(r==0);
TOKULOGGER logger;
LSN lsn = ZERO_LSN;
// log a couple of timestamp log entries
r = toku_logger_create(&logger);
assert(r == 0);
r = toku_logger_open(dname, logger);
assert(r == 0);
BYTESTRING bs0 = { .data = "hello", .len = 5 };
r = toku_log_timestamp(logger, &lsn, 0, now(), bs0);
assert(r == 0);
sleep(10);
BYTESTRING bs1 = { .data = "world", .len = 5 };
r = toku_log_timestamp(logger, &lsn, 0, now(), bs1);
assert(r == 0);
r = toku_logger_close(&logger);
assert(r == 0);
// TODO verify the log
return 0;
}
......@@ -95,6 +95,10 @@ static void wbuf_ulonglong (struct wbuf *w, u_int64_t ull) {
wbuf_uint(w, (u_int32_t)(ull&0xFFFFFFFF));
}
static inline void wbuf_u_int64_t(struct wbuf *w, u_int64_t ull) {
wbuf_ulonglong(w, ull);
}
static inline void wbuf_BYTESTRING (struct wbuf *w, BYTESTRING v) {
wbuf_bytes(w, v.data, v.len);
}
......
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