truncation.c no longer includes on pageFile.h
This commit is contained in:
parent
2d3fc4ba47
commit
26e5aa3069
6 changed files with 69 additions and 41 deletions
|
@ -96,23 +96,49 @@ BEGIN_C_DECLS
|
||||||
typedef struct Page_s Page_s;
|
typedef struct Page_s Page_s;
|
||||||
typedef struct Page_s Page;
|
typedef struct Page_s Page;
|
||||||
|
|
||||||
extern Page * (*loadPage)(int xid, int pageid);
|
|
||||||
extern void (*releasePage)(Page * p);
|
|
||||||
extern int (*bufInit)();
|
|
||||||
extern void (*bufDeinit)();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param xid The transaction that is pinning the page (used by page-level locking implementations.)
|
* @param xid The transaction that is pinning the page (used by page-level locking implementations.)
|
||||||
* @param pageid ID of the page you want to load
|
* @param pageid ID of the page you want to load
|
||||||
* @return fully formed Page type
|
* @return fully formed Page type
|
||||||
*/
|
*/
|
||||||
compensated_function Page * bufManLoadPage(int xid, int pageid);
|
extern Page * (*loadPage)(int xid, int pageid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
loadPage aquires a lock when it is called, effectively pinning it
|
loadPage aquires a lock when it is called, effectively pinning it
|
||||||
in memory. releasePage releases this lock.
|
in memory. releasePage releases this lock.
|
||||||
*/
|
*/
|
||||||
void bufManReleasePage(Page * p);
|
extern void (*releasePage)(Page * p);
|
||||||
|
/**
|
||||||
|
* initialize buffer manager
|
||||||
|
* @return 0 on success
|
||||||
|
* @return error code on failure
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
This is used by truncation to move dirty pages from Stasis cache
|
||||||
|
into the operating system cache. Once writeBackPage(p) returns,
|
||||||
|
calling forcePages() will synchronously force page number p to
|
||||||
|
disk.
|
||||||
|
|
||||||
|
(Not all buffer managers support synchronous writes to stable
|
||||||
|
storage. For compatibility, such buffer managers should ignore
|
||||||
|
this call.)
|
||||||
|
*/
|
||||||
|
extern void (*writeBackPage)(Page * p);
|
||||||
|
/**
|
||||||
|
Force any written back pages to disk.
|
||||||
|
|
||||||
|
@see writeBackPage for more information.
|
||||||
|
|
||||||
|
If the buffer manager doesn't support stable storage, this call is
|
||||||
|
a no-op.
|
||||||
|
*/
|
||||||
|
extern void (*forcePages)();
|
||||||
|
|
||||||
|
int bufInit(int type);
|
||||||
|
/**
|
||||||
|
* will write out any dirty pages, assumes that there are no running
|
||||||
|
* transactions
|
||||||
|
*/
|
||||||
|
extern void (*bufDeinit)();
|
||||||
|
|
||||||
#ifdef PROFILE_LATCHES_WRITE_ONLY
|
#ifdef PROFILE_LATCHES_WRITE_ONLY
|
||||||
#define loadPage(x,y) __profile_loadPage((x), (y), __FILE__, __LINE__)
|
#define loadPage(x,y) __profile_loadPage((x), (y), __FILE__, __LINE__)
|
||||||
|
@ -122,20 +148,15 @@ compensated_function Page * __profile_loadPage(int xid, int pageid, char * file,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/**
|
/*compensated_function Page * bufManLoadPage(int xid, int pageid);
|
||||||
* initialize buffer manager
|
|
||||||
* @return 0 on success
|
void bufManReleasePage(Page * p);
|
||||||
* @return error code on failure
|
|
||||||
*/
|
|
||||||
int bufManBufInit();
|
int bufManBufInit();
|
||||||
|
|
||||||
/**
|
|
||||||
* will write out any dirty pages, assumes that there are no running
|
|
||||||
* transactions
|
|
||||||
*/
|
|
||||||
void bufManBufDeinit();
|
void bufManBufDeinit();
|
||||||
|
|
||||||
void setBufferManager(int i);
|
void setBufferManager(int i); */
|
||||||
|
|
||||||
|
|
||||||
END_C_DECLS
|
END_C_DECLS
|
||||||
|
|
|
@ -91,7 +91,8 @@ terms specified in this license.
|
||||||
/*#define MAX_BUFFER_SIZE 7 */
|
/*#define MAX_BUFFER_SIZE 7 */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define BUFFER_MANAGER_HASH 0
|
#define BUFFER_MANAGER_REOPEN 0
|
||||||
|
#define BUFFER_MANAGER_HASH 1
|
||||||
|
|
||||||
#define MAX_TRANSACTIONS 1000
|
#define MAX_TRANSACTIONS 1000
|
||||||
|
|
||||||
|
|
|
@ -105,9 +105,9 @@ static pthread_mutex_t loadPagePtr_mutex;
|
||||||
|
|
||||||
static Page * dummy_page;
|
static Page * dummy_page;
|
||||||
|
|
||||||
pthread_key_t lastPage;
|
static pthread_key_t lastPage;
|
||||||
|
|
||||||
int bufManBufInit() {
|
static int bufManBufInit() {
|
||||||
|
|
||||||
bufferPoolInit();
|
bufferPoolInit();
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ int bufManBufInit() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void bufManBufDeinit() {
|
static void bufManBufDeinit() {
|
||||||
|
|
||||||
DEBUG("pageCacheDeinit()");
|
DEBUG("pageCacheDeinit()");
|
||||||
|
|
||||||
|
@ -178,7 +178,7 @@ void simulateBufferManagerCrash() {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void bufManReleasePage (Page * p) {
|
static void bufManReleasePage (Page * p) {
|
||||||
unlock(p->loadlatch);
|
unlock(p->loadlatch);
|
||||||
#ifdef PIN_COUNT
|
#ifdef PIN_COUNT
|
||||||
pthread_mutex_lock(&pinCount_mutex);
|
pthread_mutex_lock(&pinCount_mutex);
|
||||||
|
@ -448,7 +448,7 @@ compensated_function void __profile_releasePage(Page * p) {
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
compensated_function Page *bufManLoadPage(int xid, int pageid) {
|
static compensated_function Page *bufManLoadPage(int xid, int pageid) {
|
||||||
|
|
||||||
try_ret(NULL) {
|
try_ret(NULL) {
|
||||||
if(globalLockManager.readLockPage) { globalLockManager.readLockPage(xid, pageid); }
|
if(globalLockManager.readLockPage) { globalLockManager.readLockPage(xid, pageid); }
|
||||||
|
@ -486,14 +486,26 @@ compensated_function Page *bufManLoadPage(int xid, int pageid) {
|
||||||
|
|
||||||
Page * (*loadPage)(int xid, int pageid) = 0;
|
Page * (*loadPage)(int xid, int pageid) = 0;
|
||||||
void (*releasePage)(Page * p) = 0;
|
void (*releasePage)(Page * p) = 0;
|
||||||
int (*bufInit)() = 0;
|
void (*writeBackPage)(Page * p) = 0;
|
||||||
void (*bufDeinit)() = 0;
|
void (*forcePages)() = 0;
|
||||||
|
|
||||||
void setBufferManager(int i ) {
|
void (*bufDeinit)() = 0;
|
||||||
if(i == BUFFER_MANAGER_HASH) {
|
int bufInit(int type) {
|
||||||
|
static int lastType = 0;
|
||||||
|
if(type == BUFFER_MANAGER_REOPEN) {
|
||||||
|
type = lastType;
|
||||||
|
}
|
||||||
|
lastType = type;
|
||||||
|
if(type == BUFFER_MANAGER_HASH) {
|
||||||
releasePage = bufManReleasePage;
|
releasePage = bufManReleasePage;
|
||||||
bufInit = bufManBufInit;
|
|
||||||
loadPage = bufManLoadPage;
|
loadPage = bufManLoadPage;
|
||||||
|
writeBackPage = pageWrite;
|
||||||
|
forcePages = forcePageFile;
|
||||||
bufDeinit = bufManBufDeinit;
|
bufDeinit = bufManBufDeinit;
|
||||||
}
|
bufManBufInit();
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
// XXX error handling
|
||||||
|
abort();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,8 +103,6 @@ void setupOperationsTable() {
|
||||||
|
|
||||||
|
|
||||||
int Tinit() {
|
int Tinit() {
|
||||||
setBufferManager(BUFFER_MANAGER_HASH);
|
|
||||||
|
|
||||||
pthread_mutex_init(&transactional_2_mutex, NULL);
|
pthread_mutex_init(&transactional_2_mutex, NULL);
|
||||||
numActiveXactions = 0;
|
numActiveXactions = 0;
|
||||||
|
|
||||||
|
@ -114,10 +112,8 @@ int Tinit() {
|
||||||
dirtyPagesInit();
|
dirtyPagesInit();
|
||||||
LogInit(loggerType);
|
LogInit(loggerType);
|
||||||
pageInit();
|
pageInit();
|
||||||
bufInit();
|
bufInit(BUFFER_MANAGER_HASH);
|
||||||
// try_ret(compensation_error()) {
|
|
||||||
pageOperationsInit();
|
pageOperationsInit();
|
||||||
// } end_ret(compensation_error());
|
|
||||||
initNestedTopActions();
|
initNestedTopActions();
|
||||||
TallocInit();
|
TallocInit();
|
||||||
ThashInit();
|
ThashInit();
|
||||||
|
|
|
@ -4,8 +4,6 @@
|
||||||
#include <lladd/logger/logger2.h>
|
#include <lladd/logger/logger2.h>
|
||||||
#include "page.h"
|
#include "page.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
/** @todo truncation.c is too dependent on the bufferManager implementation. */
|
|
||||||
#include "pageFile.h"
|
|
||||||
|
|
||||||
static volatile int initialized = 0;
|
static volatile int initialized = 0;
|
||||||
static int automaticallyTuncating = 0;
|
static int automaticallyTuncating = 0;
|
||||||
|
@ -100,7 +98,7 @@ static void dirtyPages_flush() {
|
||||||
|
|
||||||
for(i = 0; i < MAX_BUFFER_SIZE && staleDirtyPages[i] != -1; i++) {
|
for(i = 0; i < MAX_BUFFER_SIZE && staleDirtyPages[i] != -1; i++) {
|
||||||
p = loadPage(-1, staleDirtyPages[i]);
|
p = loadPage(-1, staleDirtyPages[i]);
|
||||||
pageWrite(p);
|
writeBackPage(p);
|
||||||
releasePage(p);
|
releasePage(p);
|
||||||
}
|
}
|
||||||
free(staleDirtyPages);
|
free(staleDirtyPages);
|
||||||
|
@ -183,7 +181,7 @@ int truncateNow() {
|
||||||
if((rec_lsn - log_trunc) > MIN_INCREMENTAL_TRUNCATION) {
|
if((rec_lsn - log_trunc) > MIN_INCREMENTAL_TRUNCATION) {
|
||||||
// fprintf(stderr, "Truncating now. rec_lsn = %ld, log_trunc = %ld\n", rec_lsn, log_trunc);
|
// fprintf(stderr, "Truncating now. rec_lsn = %ld, log_trunc = %ld\n", rec_lsn, log_trunc);
|
||||||
// fprintf(stderr, "Truncating to rec_lsn = %ld\n", rec_lsn);
|
// fprintf(stderr, "Truncating to rec_lsn = %ld\n", rec_lsn);
|
||||||
forcePageFile();
|
forcePages();
|
||||||
LogTruncate(rec_lsn);
|
LogTruncate(rec_lsn);
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
|
@ -198,7 +196,7 @@ int truncateNow() {
|
||||||
|
|
||||||
//fprintf(stderr, "Flushed Dirty Buffers. Truncating to rec_lsn = %ld\n", rec_lsn);
|
//fprintf(stderr, "Flushed Dirty Buffers. Truncating to rec_lsn = %ld\n", rec_lsn);
|
||||||
|
|
||||||
forcePageFile();
|
forcePages();
|
||||||
LogTruncate(rec_lsn);
|
LogTruncate(rec_lsn);
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
|
|
@ -405,7 +405,7 @@ void reopenLogWorkload(int truncating) {
|
||||||
|
|
||||||
numActiveXactions = 0;
|
numActiveXactions = 0;
|
||||||
dirtyPagesInit();
|
dirtyPagesInit();
|
||||||
bufInit();
|
bufInit(BUFFER_MANAGER_REOPEN);
|
||||||
|
|
||||||
LogInit(loggerType);
|
LogInit(loggerType);
|
||||||
int xid = 1;
|
int xid = 1;
|
||||||
|
|
Loading…
Reference in a new issue