Skip to content

Commit

Permalink
remove all multi-version client code related to grv cache
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-jfu committed Feb 2, 2022
1 parent d8e7fea commit 6d05ecf
Show file tree
Hide file tree
Showing 13 changed files with 13 additions and 247 deletions.
2 changes: 0 additions & 2 deletions bindings/c/CMakeLists.txt
@@ -1,8 +1,6 @@
set(FDB_C_SRCS
fdb_c.cpp
foundationdb/fdb_c.h
foundationdb/fdb_c_internal.h
foundationdb/fdb_c_types.h
ThreadCleanup.cpp)

file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/foundationdb)
Expand Down
9 changes: 0 additions & 9 deletions bindings/c/fdb_c.cpp
Expand Up @@ -26,7 +26,6 @@
#include "fdbclient/MultiVersionTransaction.h"
#include "fdbclient/MultiVersionAssignmentVars.h"
#include "foundationdb/fdb_c.h"
#include "foundationdb/fdb_c_internal.h"

int g_api_version = 0;

Expand Down Expand Up @@ -406,14 +405,6 @@ extern "C" DLLEXPORT FDBFuture* fdb_database_create_snapshot(FDBDatabase* db,
.extractPtr());
}

extern "C" DLLEXPORT DatabaseSharedState* fdb_database_create_shared_state(FDBDatabase* db) {
return (DatabaseSharedState*)(DB(db)->createSharedState());
}

extern "C" DLLEXPORT void fdb_database_set_shared_state(FDBDatabase* db, DatabaseSharedState* p) {
(DB(db)->setSharedState(p));
}

// Get network thread busyness (updated every 1s)
// A value of 0 indicates that the client is more or less idle
// A value of 1 (or more) indicates that the client is saturated
Expand Down
10 changes: 9 additions & 1 deletion bindings/c/foundationdb/fdb_c.h
Expand Up @@ -58,12 +58,20 @@
#include <stdint.h>

#include "fdb_c_options.g.h"
#include "fdb_c_types.h"

#ifdef __cplusplus
extern "C" {
#endif

/* Pointers to these opaque types represent objects in the FDB API */
typedef struct FDB_future FDBFuture;
typedef struct FDB_result FDBResult;
typedef struct FDB_database FDBDatabase;
typedef struct FDB_transaction FDBTransaction;

typedef int fdb_error_t;
typedef int fdb_bool_t;

DLLEXPORT const char* fdb_get_error(fdb_error_t code);

DLLEXPORT fdb_bool_t fdb_error_predicate(int predicate_test, fdb_error_t code);
Expand Down
45 changes: 0 additions & 45 deletions bindings/c/foundationdb/fdb_c_internal.h

This file was deleted.

45 changes: 0 additions & 45 deletions bindings/c/foundationdb/fdb_c_types.h

This file was deleted.

5 changes: 0 additions & 5 deletions fdbclient/DatabaseContext.h
Expand Up @@ -468,11 +468,6 @@ class DatabaseContext : public ReferenceCounted<DatabaseContext>, public FastAll
int outstandingWatches;
int maxOutstandingWatches;

// Manage any shared state that may be used by MVC
DatabaseSharedState* sharedStatePtr;
DatabaseSharedState* initSharedState();
void setSharedState(DatabaseSharedState* p);

// GRV Cache
// Database-level read version cache storing the most recent successful GRV as well as the time it was requested.
double lastTimedGrv;
Expand Down
16 changes: 0 additions & 16 deletions fdbclient/FDBTypes.h
Expand Up @@ -1171,22 +1171,6 @@ struct StorageMigrationType {
uint32_t type;
};

struct GRVCacheSpace {
Version cachedRv;
double lastTimedGrv;

GRVCacheSpace() : cachedRv(Version(0)), lastTimedGrv(0.0) {}
};

// This structure can be extended in the future to include additional features that required a shared state
struct DatabaseSharedState {
Mutex mutexLock;
GRVCacheSpace grvCacheSpace;
int refCount;

DatabaseSharedState() : mutexLock(Mutex()), grvCacheSpace(GRVCacheSpace()) {}
};

inline bool isValidPerpetualStorageWiggleLocality(std::string locality) {
int pos = locality.find(':');
// locality should be either 0 or in the format '<non_empty_string>:<non_empty_string>'
Expand Down
4 changes: 0 additions & 4 deletions fdbclient/IClientApi.h
Expand Up @@ -137,10 +137,6 @@ class IDatabase {
// Management API, create snapshot
virtual ThreadFuture<Void> createSnapshot(const StringRef& uid, const StringRef& snapshot_command) = 0;

// Interface to manage shared state across multiple connections to the same Database
virtual DatabaseSharedState* createSharedState() = 0;
virtual void setSharedState(DatabaseSharedState* p) = 0;

// used in template functions as the Transaction type that can be created through createTransaction()
using TransactionT = ITransaction;
};
Expand Down
44 changes: 0 additions & 44 deletions fdbclient/MultiVersionTransaction.actor.cpp
Expand Up @@ -446,19 +446,6 @@ ThreadFuture<Void> DLDatabase::createSnapshot(const StringRef& uid, const String
return toThreadFuture<Void>(api, f, [](FdbCApi::FDBFuture* f, FdbCApi* api) { return Void(); });
}

DatabaseSharedState* DLDatabase::createSharedState() {
if (!api->databaseCreateSharedState) {
return nullptr;
}
return api->databaseCreateSharedState(db);
}

void DLDatabase::setSharedState(DatabaseSharedState* p) {
if (api->databaseSetSharedState) {
api->databaseSetSharedState(db, p);
}
}

// Get network thread busyness
double DLDatabase::getMainThreadBusyness() {
if (api->databaseGetMainThreadBusyness != nullptr) {
Expand Down Expand Up @@ -736,7 +723,6 @@ Reference<IDatabase> DLApi::createDatabase609(const char* clusterFilePath) {
Reference<IDatabase> DLApi::createDatabase(const char* clusterFilePath) {
if (headerVersion >= 610) {
FdbCApi::FDBDatabase* db;
// can the FdbCApi wrapper signature be changed to add this ptr?
throwIfError(api->createDatabase(clusterFilePath, &db));
return Reference<IDatabase>(new DLDatabase(api, db));
} else {
Expand Down Expand Up @@ -1191,14 +1177,6 @@ MultiVersionDatabase::MultiVersionDatabase(MultiVersionApi* api,
: dbState(new DatabaseState(clusterFilePath, versionMonitorDb)) {
dbState->db = db;
dbState->dbVar->set(db);
auto stateMapKey = std::make_pair(clusterFilePath, dbState->dbProtocolVersion.get());
if (api->clusterSharedStateMap.find(stateMapKey) == api->clusterSharedStateMap.end() ||
api->clusterSharedStateMap[stateMapKey] == nullptr) {
DatabaseSharedState* p = db->createSharedState();
api->clusterSharedStateMap[stateMapKey] = p;
} else {
db->setSharedState(api->clusterSharedStateMap[stateMapKey]);
}
if (openConnectors) {
if (!api->localClientDisabled) {
dbState->addClient(api->getLocalClient());
Expand Down Expand Up @@ -1308,19 +1286,6 @@ ThreadFuture<Void> MultiVersionDatabase::createSnapshot(const StringRef& uid, co
return abortableFuture(f, dbState->dbVar->get().onChange);
}

DatabaseSharedState* MultiVersionDatabase::createSharedState() {
if (dbState->db) {
return dbState->db->createSharedState();
}
return nullptr;
}

void MultiVersionDatabase::setSharedState(DatabaseSharedState* p) {
if (dbState->db) {
dbState->db->setSharedState(p);
}
}

// Get network thread busyness
// Return the busyness for the main thread. When using external clients, take the larger of the local client
// and the external client's busyness.
Expand Down Expand Up @@ -1538,15 +1503,6 @@ void MultiVersionDatabase::DatabaseState::updateDatabase(Reference<IDatabase> ne
}
}

auto stateMapKey = std::make_pair(clusterFilePath, dbProtocolVersion.get());
if (MultiVersionApi::api->clusterSharedStateMap.find(stateMapKey) ==
MultiVersionApi::api->clusterSharedStateMap.end() ||
MultiVersionApi::api->clusterSharedStateMap[stateMapKey] == nullptr) {
DatabaseSharedState* p = db->createSharedState();
MultiVersionApi::api->clusterSharedStateMap[stateMapKey] = p;
} else {
db->setSharedState(MultiVersionApi::api->clusterSharedStateMap[stateMapKey]);
}
dbVar->set(db);

ASSERT(protocolVersionMonitor.isValid());
Expand Down
10 changes: 0 additions & 10 deletions fdbclient/MultiVersionTransaction.h
Expand Up @@ -108,8 +108,6 @@ struct FdbCApi : public ThreadSafeReferenceCounted<FdbCApi> {
int uidLength,
uint8_t const* snapshotCommmand,
int snapshotCommandLength);
DatabaseSharedState* (*databaseCreateSharedState)(FDBDatabase* database);
void (*databaseSetSharedState)(FDBDatabase* database, DatabaseSharedState* p);

double (*databaseGetMainThreadBusyness)(FDBDatabase* database);
FDBFuture* (*databaseGetServerProtocol)(FDBDatabase* database, uint64_t expectedVersion);
Expand Down Expand Up @@ -362,9 +360,6 @@ class DLDatabase : public IDatabase, ThreadSafeReferenceCounted<DLDatabase> {
ThreadFuture<Void> forceRecoveryWithDataLoss(const StringRef& dcid) override;
ThreadFuture<Void> createSnapshot(const StringRef& uid, const StringRef& snapshot_command) override;

DatabaseSharedState* createSharedState() override;
void setSharedState(DatabaseSharedState* p) override;

private:
const Reference<FdbCApi> api;
FdbCApi::FDBDatabase*
Expand Down Expand Up @@ -593,9 +588,6 @@ class MultiVersionDatabase final : public IDatabase, ThreadSafeReferenceCounted<
ThreadFuture<Void> forceRecoveryWithDataLoss(const StringRef& dcid) override;
ThreadFuture<Void> createSnapshot(const StringRef& uid, const StringRef& snapshot_command) override;

DatabaseSharedState* createSharedState() override;
void setSharedState(DatabaseSharedState* p) override;

// private:

struct LegacyVersionMonitor;
Expand Down Expand Up @@ -718,8 +710,6 @@ class MultiVersionApi : public IClientApi {

bool callbackOnMainThread;
bool localClientDisabled;
// Map of (clusterFilePath + protocolVersion) -> DatabaseSharedState pointer
std::map<std::pair<std::string, ProtocolVersion>, DatabaseSharedState*> clusterSharedStateMap;

static bool apiVersionAtLeast(int minVersion);

Expand Down

0 comments on commit 6d05ecf

Please sign in to comment.