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

{{{DB_ENV->log_archive}}} understands checkpoints, but not live transactions. ...

{{{DB_ENV->log_archive}}} understands checkpoints, but not live transactions.  Addresses #75, #83, #392.

git-svn-id: file:///svn/tokudb@3003 c7de825b-a66e-492c-adef-691d508d4ae1
parent ad623fbf
......@@ -735,6 +735,7 @@ int toku_cachetable_checkpoint (CACHETABLE ct) {
//?? This is a skeleton. It compiles, but doesn't do anything reasonable yet.
//?? log_the_checkpoint();
int n_saved=0;
int n_in_table = ct->n_in_table;
struct save_something {
......
......@@ -86,4 +86,6 @@ FILENUM toku_cachefile_filenum (CACHEFILE);
// During a transaction, we cannot reuse a filenum.
int toku_cachefile_of_filenum (CACHETABLE t, FILENUM filenum, CACHEFILE *cf, BRT *brt);
int toku_cachetable_checkpoint (CACHETABLE ct);
#endif
......@@ -116,7 +116,7 @@ static inline int toku_logsizeof_LOGGEDBRTHEADER (LOGGEDBRTHEADER bs) {
int sum_of_pieces=0;
int i;
for (i=0; i<bs.n_named_roots; i++) {
sum_of_pieces += 8+1+strlen(bs.u.many.names[i]);
sum_of_pieces += 4+8+1+strlen(bs.u.many.names[i]);
}
return in_both+sum_of_pieces;
}
......
......@@ -374,6 +374,10 @@ int toku_logger_commit (TOKUTXN txn, int nosync) {
int toku_logger_log_checkpoint (TOKULOGGER logger) {
if (logger->is_panicked) return EINVAL;
int r = toku_cachetable_checkpoint(logger->ct);
if (r!=0) return r;
logger->checkpoint_lsns[1]=logger->checkpoint_lsns[0];
logger->checkpoint_lsns[0]=logger->lsn;
return toku_log_checkpoint(logger, 1);
}
......@@ -741,17 +745,23 @@ int toku_logger_log_archive (TOKULOGGER logger, char ***logs_p, int flags) {
// Count the total number of bytes, because we have to return a single big array. (That's the BDB interface. Bleah...)
LSN earliest_lsn_seen={(unsigned long long)(-1LL)};
r = peek_at_log(logger, all_logs[all_n_logs-1], &earliest_lsn_seen); // try to find the lsn that's in the most recent log
for (i=all_n_logs-2; i>=0; i--) { // start at all_n_logs-2 because we never archive the most recent log
r = peek_at_log(logger, all_logs[i], &earliest_lsn_seen);
if (r!=0) continue; // In case of error, just keep going
if ((earliest_lsn_seen.lsn <= logger->checkpoint_lsns[0].lsn)&&
(earliest_lsn_seen.lsn <= logger->checkpoint_lsns[1].lsn)) {
break;
if ((earliest_lsn_seen.lsn <= logger->checkpoint_lsns[0].lsn)&&
(earliest_lsn_seen.lsn <= logger->checkpoint_lsns[1].lsn)) {
i=all_n_logs-1;
} else {
for (i=all_n_logs-2; i>=0; i--) { // start at all_n_logs-2 because we never archive the most recent log
r = peek_at_log(logger, all_logs[i], &earliest_lsn_seen);
if (r!=0) continue; // In case of error, just keep going
printf("%s:%d file=%s firstlsn=%lld checkpoint_lsns={%lld %lld}\n", __FILE__, __LINE__, all_logs[i], (long long)earliest_lsn_seen.lsn, (long long)logger->checkpoint_lsns[0].lsn, (long long)logger->checkpoint_lsns[1].lsn);
if ((earliest_lsn_seen.lsn <= logger->checkpoint_lsns[0].lsn)&&
(earliest_lsn_seen.lsn <= logger->checkpoint_lsns[1].lsn)) {
break;
}
}
}
// all log files up to, but not including i can be archived.
// all log files up to, but but not including, i can be archived.
int n_to_archive=i;
int count_bytes=0;
for (i=0; i<n_to_archive; i++) {
......@@ -770,7 +780,7 @@ int toku_logger_log_archive (TOKULOGGER logger, char ***logs_p, int flags) {
free(all_logs[i]);
}
free(all_logs);
result[i]=0;
result[n_to_archive]=0;
*logs_p = result;
return 0;
}
......@@ -84,6 +84,7 @@ void do_test_abort2 (void) {
// Don't do a lookup on "hello7", because that will force things out of the buffer.
r=db->close(db, 0); CKERR(r);
printf("%s:%d\n", __FILE__, __LINE__);
r=db_create(&db, env, 0); CKERR(r);
r=db->open(db, txn, "foo.db", 0, DB_BTREE, 0, 0777); CKERR(r);
printf("%s:%d\n", __FILE__, __LINE__);
......
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