mirror of
https://github.com/mongodb/mongo.git
synced 2024-11-30 00:56:44 +01:00
dur
This commit is contained in:
parent
dad0b0bb25
commit
62d48d63dd
28
db/dur.cpp
28
db/dur.cpp
@ -22,7 +22,7 @@
|
||||
PREPLOGBUFFER
|
||||
we will build an output buffer ourself and then use O_DIRECT
|
||||
we could be in read lock for this
|
||||
for very large objects write directly to redo log in situ? will be faster.
|
||||
for very large objects write directly to redo log in situ?
|
||||
WRITETOREDOLOG
|
||||
we could be unlocked (the main db lock that is...) for this, with sufficient care, but there is some complexity
|
||||
have to handle falling behind which would use too much ram (going back into a read lock would suffice to stop that).
|
||||
@ -58,8 +58,8 @@ namespace mongo {
|
||||
struct WriteIntent {
|
||||
WriteIntent() : p(0) { }
|
||||
WriteIntent(void *a, unsigned b) : p(a), len(b) { }
|
||||
void *p;
|
||||
unsigned len;
|
||||
void *p; // where we will write
|
||||
unsigned len; // up to this len
|
||||
};
|
||||
|
||||
/* try to remember things we have already marked for journalling. false negatives are ok if infrequent -
|
||||
@ -72,19 +72,24 @@ namespace mongo {
|
||||
public:
|
||||
Already() { reset(); }
|
||||
void reset() { memset(this, 0, sizeof(*this)); }
|
||||
|
||||
/* see if we have Already recorded/indicated our write intent for this region of memory.
|
||||
@return true if already indicated.
|
||||
*/
|
||||
bool checkAndSet(const WriteIntent& w) {
|
||||
mongoutils::hash(123);
|
||||
unsigned x = mongoutils::hashPointer(w.p);
|
||||
WriteIntent& n = nodes[x % N];
|
||||
if( n.p != w.p || n.len < w.len ) {
|
||||
n = w;
|
||||
WriteIntent& nd = nodes[x % N];
|
||||
if( nd.p != w.p || nd.len < w.len ) {
|
||||
nd = w;
|
||||
return false;
|
||||
}
|
||||
return true; // already done
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
static Already<127> alreadyNoted;
|
||||
|
||||
/* our record of pending/uncommitted write intents */
|
||||
static vector<WriteIntent> writes;
|
||||
|
||||
void* writingPtr(void *x, size_t len) {
|
||||
@ -100,6 +105,13 @@ namespace mongo {
|
||||
return x;
|
||||
}
|
||||
|
||||
void durThread() {
|
||||
}
|
||||
|
||||
void startup() {
|
||||
boost::thread t(durThread);
|
||||
}
|
||||
|
||||
} // namespace dur
|
||||
|
||||
} // namespace mongo
|
||||
|
9
db/dur.h
9
db/dur.h
@ -10,6 +10,7 @@ namespace mongo {
|
||||
namespace dur {
|
||||
|
||||
#if !defined(_DURABLE)
|
||||
inline void startup() { }
|
||||
inline void* writingPtr(void *x, size_t len) { return x; }
|
||||
inline DiskLoc& writingDiskLoc(DiskLoc& d) { return d; }
|
||||
inline int& writingInt(int& d) { return d; }
|
||||
@ -18,6 +19,9 @@ namespace mongo {
|
||||
template <typename T> inline T* writingNoLog(T *x) { return x; }
|
||||
#else
|
||||
|
||||
/** call during startup so durability module can initialize */
|
||||
void startup();
|
||||
|
||||
/** Declarations of write intent.
|
||||
|
||||
Use these methods to declare "i'm about to write to x and it should be logged for redo."
|
||||
@ -44,12 +48,13 @@ namespace mongo {
|
||||
}
|
||||
|
||||
/** declare our intent to write, but it doesn't have to be journaled, as this write is
|
||||
something 'unimportant'.
|
||||
something 'unimportant'. depending on our implementation, we may or may not be able
|
||||
to take advantage of this versus doing the normal work we do.
|
||||
*/
|
||||
template <typename T>
|
||||
inline
|
||||
T* writingNoLog(T *x) {
|
||||
log() << "todo dur nolog not yet optimized" << endl;
|
||||
DEV RARELY log() << "todo dur nolog not yet optimized" << endl;
|
||||
return (T*) writingPtr(x, sizeof(T));
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
// @file dur_journal.cpp
|
||||
|
||||
// @file dur_journal.cpp
|
||||
|
||||
/**
|
||||
* Copyright (C) 2010 10gen Inc.
|
||||
*
|
||||
@ -37,7 +37,7 @@ namespace mongo {
|
||||
/* temp - this will become more elaborate and probably a class. */
|
||||
|
||||
|
||||
/** call at init. uasserts on failure. if fails, you likely want to terminate. */
|
||||
/** call at init. uasserts on failure. if fails, you likely want to terminate. */
|
||||
void openJournal() {
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
// @file dur_journal.h
|
||||
|
||||
// @file dur_journal.h
|
||||
|
||||
/**
|
||||
* Copyright (C) 2010 10gen Inc.
|
||||
*
|
||||
@ -21,7 +21,7 @@
|
||||
namespace mongo {
|
||||
namespace dur {
|
||||
|
||||
/** call at init. uasserts on failure. if fails, you likely want to terminate. */
|
||||
/** call at init. uasserts on failure. if fails, you likely want to terminate. */
|
||||
void openJournal();
|
||||
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
// dbtests.cpp : Runs db unit tests.
|
||||
// #file dbtests.cpp : Runs db unit tests.
|
||||
//
|
||||
|
||||
/**
|
||||
@ -18,11 +18,9 @@
|
||||
*/
|
||||
|
||||
#include "pch.h"
|
||||
|
||||
#include "dbtests.h"
|
||||
|
||||
int main( int argc, char** argv ) {
|
||||
static StaticObserver StaticObserver;
|
||||
return Suite::run(argc, argv, "/tmp/unittest");
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
#include "framework.h"
|
||||
#include "../util/file_allocator.h"
|
||||
#include "../db/dur.h"
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <cxxabi.h>
|
||||
@ -250,6 +251,8 @@ namespace mongo {
|
||||
filter = params["filter"].as<string>();
|
||||
}
|
||||
|
||||
dur::startup();
|
||||
|
||||
int ret = run(suites,filter);
|
||||
|
||||
#if !defined(_WIN32) && !defined(__sunos__)
|
||||
|
Loading…
Reference in New Issue
Block a user