* Remove spurious warnings messages from tests that intentionally crash stasis.

* Move and rename lladd_autoTruncation flag to stasis_truncation_automatic in flags.c
This commit is contained in:
Sears Russell 2007-10-23 23:16:58 +00:00
parent 9b8fefe68d
commit b167b98085
9 changed files with 77 additions and 38 deletions

View file

@ -72,7 +72,6 @@ terms specified in this license.
#include <stasis/lockManager.h>
#include <stasis/pageCache.h>
#include <stasis/pageHandle.h>
#include <stasis/truncation.h>
#include <stasis/lhtable.h>

View file

@ -1,11 +1,11 @@
#include <pthread.h>
#include <config.h>
#include "bufferManager/bufferHash.h"
#include <stasis/bufferPool.h>
#include <stasis/doubleLinkedList.h>
#include <stasis/lhtable.h>
#include <stasis/bufferPool.h>
#include <stasis/pageHandle.h>

View file

@ -9,7 +9,7 @@ int bufferManagerType = BUFFER_MANAGER_HASH;
#endif
#ifdef BUFFER_MANAGER_O_DIRECT
int bufferManagerO_DIRECT = 1;
int bufferManagerO_DIRECT = BUFFER_MANAGER_O_DIRECT;
#else
int bufferManagerO_DIRECT = 0;
#endif
@ -26,3 +26,14 @@ int bufferManagerNonBlockingSlowHandleType
#else
int bufferManagerNonBlockingSlowHandleType = IO_HANDLE_PFILE;
#endif
#ifdef STASIS_SUPPRESS_UNCLEAN_SHUTDOWN_WARNINGS
#error stasus_suppress_unclean_shutdown_warnings cannot be set at compile time.
#endif
int stasis_suppress_unclean_shutdown_warnings = 0;
#ifdef STASIS_TRUNCATION_AUTOMATIC
int stasis_truncation_automatic = STASIS_TRUNCATION_AUTOMATIC;
#else
int stasis_truncation_automatic = 1;
#endif

View file

@ -221,7 +221,7 @@ int Tinit() {
InitiateRecovery();
truncationInit();
if(lladd_enableAutoTruncation) {
if(stasis_truncation_automatic) {
autoTruncate(); // should this be before InitiateRecovery?
}
return 0;
@ -397,34 +397,40 @@ int Tabort(int xid) {
}
int Tdeinit() {
int i;
int i;
for( i = 0; i < MAX_TRANSACTIONS; i++ ) {
if( XactionTable[i].xid != INVALID_XTABLE_XID ) {
fprintf(stderr, "WARNING: Tdeinit() is aborting transaction %d\n", XactionTable[i].xid);
Tabort(XactionTable[i].xid);
}
}
assert( numActiveXactions == 0 );
truncationDeinit();
ThashDeinit();
TallocDeinit();
deinitNestedTopActions();
bufDeinit();
DEBUG("Closing page file tdeinit\n");
closePageFile();
if(slow_pfile) {
slow_close(slow_pfile);
slow_pfile = 0;
slow_close = 0;
}
stasis_page_deinit();
LogDeinit();
dirtyPagesDeinit();
return 0;
for( i = 0; i < MAX_TRANSACTIONS; i++ ) {
if( XactionTable[i].xid != INVALID_XTABLE_XID ) {
if(!stasis_suppress_unclean_shutdown_warnings) {
fprintf(stderr, "WARNING: Tdeinit() is aborting transaction %d\n",
XactionTable[i].xid);
}
Tabort(XactionTable[i].xid);
}
}
assert( numActiveXactions == 0 );
truncationDeinit();
ThashDeinit();
TallocDeinit();
deinitNestedTopActions();
bufDeinit();
DEBUG("Closing page file tdeinit\n");
closePageFile();
if(slow_pfile) {
slow_close(slow_pfile);
slow_pfile = 0;
slow_close = 0;
}
stasis_page_deinit();
LogDeinit();
dirtyPagesDeinit();
return 0;
}
int TuncleanShutdown() {
// We're simulating a crash; don't complain when writes get lost,
// and active transactions get rolled back.
stasis_suppress_unclean_shutdown_warnings = 1;
truncationDeinit();
ThashDeinit();
simulateBufferManagerCrash();
@ -437,6 +443,10 @@ int TuncleanShutdown() {
LogDeinit();
numActiveXactions = 0;
dirtyPagesDeinit();
// Reset it here so the warnings will appear if a new stasis
// instance encounters problems during a clean shutdown.
stasis_suppress_unclean_shutdown_warnings = 0;
return 0;
}

View file

@ -15,7 +15,6 @@ static pthread_cond_t shutdown_cond = PTHREAD_COND_INITIALIZER;
static pblHashTable_t * dirtyPages = 0;
static pthread_mutex_t dirtyPages_mutex = PTHREAD_MUTEX_INITIALIZER;
int lladd_enableAutoTruncation = 1;
#ifdef LONG_TEST
#define TARGET_LOG_SIZE (1024 * 1024 * 5)
#define TRUNCATE_INTERVAL 1
@ -114,8 +113,10 @@ void dirtyPagesDeinit() {
int areDirty = 0;
for(tmp = pblHtFirst(dirtyPages); tmp; tmp = pblHtNext(dirtyPages)) {
free(pblHtCurrent(dirtyPages));
if(!areDirty) {
printf("Warning: dirtyPagesDeinit detected dirty, unwritten pages. Updates lost?\n");
if((!areDirty) &&
(!stasis_suppress_unclean_shutdown_warnings)) {
printf("Warning: dirtyPagesDeinit detected dirty, unwritten pages. "
"Updates lost?\n");
areDirty = 1;
}
}

View file

@ -38,4 +38,23 @@ extern int bufferManagerNonBlockingSlowHandleType;
defining BUFFER_MANAGER_O_DIRECT.
*/
extern int bufferManagerO_DIRECT;
/**
If true, Stasis will suppress warnings regarding unclean shutdowns.
This is use to prevent spurious warnings during unit testing, and
must be set after Tinit() is called. (Tinit() resets this value to
false).
(This should not be set by applications, or during compilation.)
*/
extern int stasis_suppress_unclean_shutdown_warnings;
/*
Truncation options
*/
/**
If true, Stasis will spawn a background thread that periodically
truncates the log.
*/
extern int stasis_truncation_automatic;
#endif

View file

@ -68,8 +68,6 @@ int dirtyPages_isDirty(Page * p);
void truncationInit();
void truncationDeinit();
extern int lladd_enableAutoTruncation;
/**
Spawn a periodic, demand-based log truncation thread.
*/

View file

@ -72,7 +72,7 @@ static void setup_log() {
lsn_t prevLSN = -1;
int xid = 42;
deleteLogWriter();
lladd_enableAutoTruncation = 0;
stasis_truncation_automatic = 0;
Tinit();
lsn_t firstLSN = -1;
int first = 1;
@ -387,11 +387,10 @@ START_TEST(loggerCheckThreaded) {
void reopenLogWorkload(int truncating) {
lladd_enableAutoTruncation = 0;
stasis_truncation_automatic = 0;
const int ENTRY_COUNT = 1000;
const int SYNC_POINT = 900;
lladd_enableAutoTruncation = 0;
numActiveXactions = 0;
@ -473,7 +472,7 @@ void reopenLogWorkload(int truncating) {
assert(i == (ENTRY_COUNT * 2));
lladd_enableAutoTruncation = 1;
stasis_truncation_automatic = 1;
LogDeinit();
}

View file

@ -462,6 +462,7 @@ START_TEST (recovery_multiple_xacts) {
TuncleanShutdown();
Tinit();
stasis_suppress_unclean_shutdown_warnings = 1;
Tdeinit();
Tinit();
@ -480,6 +481,7 @@ START_TEST (recovery_multiple_xacts) {
fail_unless(j3 == 4, NULL);
fail_unless(j4 == 4, NULL);
assert(j4 == 4);
stasis_suppress_unclean_shutdown_warnings = 1;
Tdeinit();
} END_TEST