mirror of
https://github.com/apple/foundationdb.git
synced 2025-06-02 03:12:12 +08:00
Store a smaller tenant object in the txn state store
This commit is contained in:
parent
9b906d9b3d
commit
dd650215d4
@ -54,6 +54,29 @@ TenantLockState stringToTenantLockState(std::string stateStr);
|
||||
json_spirit::mObject binaryToJson(StringRef bytes);
|
||||
|
||||
struct MetaclusterTenantMapEntry;
|
||||
|
||||
struct TenantMapEntryTxnStateStore {
|
||||
constexpr static FileIdentifier file_identifier = 11267001;
|
||||
|
||||
int64_t id = -1;
|
||||
TenantName tenantName;
|
||||
TenantAPI::TenantLockState tenantLockState = TenantAPI::TenantLockState::UNLOCKED;
|
||||
|
||||
TenantMapEntryTxnStateStore() {}
|
||||
TenantMapEntryTxnStateStore(int64_t id, TenantName tenantName, TenantAPI::TenantLockState tenantLockState)
|
||||
: id(id), tenantName(tenantName), tenantLockState(tenantLockState) {}
|
||||
|
||||
Value encode() const { return ObjectWriter::toValue(*this, IncludeVersion()); }
|
||||
static TenantMapEntryTxnStateStore decode(ValueRef const& value) {
|
||||
return ObjectReader::fromStringRef<TenantMapEntryTxnStateStore>(value, IncludeVersion());
|
||||
}
|
||||
|
||||
template <class Ar>
|
||||
void serialize(Ar& ar) {
|
||||
serializer(ar, id, tenantLockState, tenantName);
|
||||
}
|
||||
};
|
||||
|
||||
struct TenantMapEntry {
|
||||
constexpr static FileIdentifier file_identifier = 7054389;
|
||||
|
||||
@ -80,6 +103,10 @@ struct TenantMapEntry {
|
||||
return ObjectReader::fromStringRef<TenantMapEntry>(value, IncludeVersion());
|
||||
}
|
||||
|
||||
TenantMapEntryTxnStateStore toTxnStateStoreEntry() const {
|
||||
return TenantMapEntryTxnStateStore(id, tenantName, tenantLockState);
|
||||
}
|
||||
|
||||
bool operator==(TenantMapEntry const& other) const;
|
||||
bool operator!=(TenantMapEntry const& other) const;
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "fdbclient/MutationList.h"
|
||||
#include "fdbclient/Notified.h"
|
||||
#include "fdbclient/SystemData.h"
|
||||
#include "fdbclient/Tenant.h"
|
||||
#include "fdbserver/ApplyMetadataMutation.h"
|
||||
#include "fdbserver/IKeyValueStore.h"
|
||||
#include "fdbserver/Knobs.h"
|
||||
@ -688,7 +689,15 @@ private:
|
||||
void checkSetTenantMapPrefix(MutationRef m) {
|
||||
KeyRef prefix = TenantMetadata::tenantMap().subspace.begin;
|
||||
if (m.param1.startsWith(prefix)) {
|
||||
TenantMapEntry tenantEntry = TenantMapEntry::decode(m.param2);
|
||||
TenantMapEntry tenantEntry;
|
||||
if (initialCommit) {
|
||||
TenantMapEntryTxnStateStore txnStateStoreEntry = TenantMapEntryTxnStateStore::decode(m.param2);
|
||||
tenantEntry.setId(txnStateStoreEntry.id);
|
||||
tenantEntry.tenantName = txnStateStoreEntry.tenantName;
|
||||
tenantEntry.tenantLockState = txnStateStoreEntry.tenantLockState;
|
||||
} else {
|
||||
tenantEntry = TenantMapEntry::decode(m.param2);
|
||||
}
|
||||
|
||||
if (tenantMap) {
|
||||
ASSERT(version != invalidVersion);
|
||||
@ -712,7 +721,7 @@ private:
|
||||
}
|
||||
|
||||
if (!initialCommit) {
|
||||
txnStateStore->set(KeyValueRef(m.param1, m.param2));
|
||||
txnStateStore->set(KeyValueRef(m.param1, tenantEntry.toTxnStateStoreEntry().encode()));
|
||||
}
|
||||
|
||||
// For now, this goes to all storage servers.
|
||||
|
Loading…
x
Reference in New Issue
Block a user