fix bug exposed by new group commit behavior; nextUnstableLSN was returning the offset of the beginning of the CRC entry, not the end of it. This was causing an assertion to fail.

This commit is contained in:
Sears Russell 2010-01-21 18:28:34 +00:00
parent 250223086c
commit f2ee7b6573
3 changed files with 18 additions and 4 deletions

View file

@ -53,11 +53,11 @@ void stasis_log_group_force(stasis_log_group_force_t* lh, lsn_t lsn) {
pthread_mutex_lock(&lh->check_commit); pthread_mutex_lock(&lh->check_commit);
if(lsn == INVALID_LSN) { if(lsn == INVALID_LSN) {
lsn = lh->log->first_unstable_lsn(lh->log,LOG_FORCE_COMMIT); lsn = lh->log->first_unstable_lsn(lh->log,LOG_FORCE_COMMIT);
} } else if(lh->log->first_unstable_lsn(lh->log,LOG_FORCE_COMMIT) > lsn) {
if(lh->log->first_unstable_lsn(lh->log,LOG_FORCE_COMMIT) > lsn) {
pthread_mutex_unlock(&lh->check_commit); pthread_mutex_unlock(&lh->check_commit);
return; return;
} }
if(lh->log->is_durable(lh->log)) { if(lh->log->is_durable(lh->log)) {
struct timeval now; struct timeval now;
struct timespec timeout; struct timespec timeout;
@ -97,7 +97,6 @@ void stasis_log_group_force(stasis_log_group_force_t* lh, lsn_t lsn) {
if(lh->log->first_unstable_lsn(lh->log,LOG_FORCE_COMMIT) <= lsn) { if(lh->log->first_unstable_lsn(lh->log,LOG_FORCE_COMMIT) <= lsn) {
lh->log->force_tail(lh->log, LOG_FORCE_COMMIT); lh->log->force_tail(lh->log, LOG_FORCE_COMMIT);
lh->minNumActive = 0; lh->minNumActive = 0;
assert(lh->log->first_unstable_lsn(lh->log,LOG_FORCE_COMMIT) > lsn);
pthread_cond_broadcast(&lh->tooFewXacts); pthread_cond_broadcast(&lh->tooFewXacts);
} }
assert(lh->log->first_unstable_lsn(lh->log,LOG_FORCE_COMMIT) > lsn); assert(lh->log->first_unstable_lsn(lh->log,LOG_FORCE_COMMIT) > lsn);

View file

@ -421,7 +421,7 @@ static void syncLog_LogWriter(stasis_log_t * log,
stasis_log_safe_writes_state* sw = log->impl; stasis_log_safe_writes_state* sw = log->impl;
lsn_t newFlushedLSN; lsn_t newFlushedLSN;
newFlushedLSN = log_crc_entry(log); newFlushedLSN = log_crc_entry(log) + sizeofInternalLogEntry_LogWriter(log, 0);
fflush(sw->fp); fflush(sw->fp);

View file

@ -594,12 +594,27 @@ START_TEST(loggerTruncateReopenTest) {
reopenLogWorkload(1); reopenLogWorkload(1);
} END_TEST } END_TEST
static void loggerEmptyForce_helper() {
Tinit();
int xid = Tbegin();
TsoftCommit(xid);
TforceCommits();
Tdeinit();
}
START_TEST(loggerEmptyFileForceTest) {
stasis_log_type = LOG_TO_FILE;
} END_TEST
START_TEST(loggerEmptyMemForceTest) {
stasis_log_type = LOG_TO_MEMORY;
} END_TEST
Suite * check_suite(void) { Suite * check_suite(void) {
Suite *s = suite_create("logWriter"); Suite *s = suite_create("logWriter");
/* Begin a new test */ /* Begin a new test */
TCase *tc = tcase_create("writeNew"); TCase *tc = tcase_create("writeNew");
tcase_set_timeout(tc, 0); tcase_set_timeout(tc, 0);
/* Sub tests are added, one per line, here */ /* Sub tests are added, one per line, here */
tcase_add_test(tc, loggerEmptyFileForceTest);
tcase_add_test(tc, loggerEmptyMemForceTest);
tcase_add_test(tc, loggerFileTest); tcase_add_test(tc, loggerFileTest);
tcase_add_test(tc, loggerMemTest); tcase_add_test(tc, loggerMemTest);
tcase_add_test(tc, logHandleFileColdReverseIterator); tcase_add_test(tc, logHandleFileColdReverseIterator);