mirror of
https://github.com/apple/foundationdb.git
synced 2025-06-03 03:41:53 +08:00
Serialize throttle limits with expiration expressed as a duration to avoid clock differences.
This commit is contained in:
parent
d2504c08c3
commit
ede69c5141
@ -85,7 +85,7 @@ public:
|
||||
}
|
||||
|
||||
//private:
|
||||
Arena arena; // TODO: where to hold this memory?
|
||||
Arena arena;
|
||||
std::set<TransactionTagRef> tags;
|
||||
size_t bytes;
|
||||
};
|
||||
@ -125,7 +125,10 @@ struct dynamic_size_traits<TagSet> : std::true_type {
|
||||
t.bytes += tag.size();
|
||||
}
|
||||
|
||||
t.arena = context.arena(); // TODO: this arena could be big
|
||||
// Deserialized tag sets share the arena with the request that contained them
|
||||
// For this reason, persisting a TagSet that shares memory with other request
|
||||
// members should be done with caution.
|
||||
t.arena = context.arena();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -61,7 +61,17 @@ struct ClientTagThrottleLimits {
|
||||
|
||||
template <class Archive>
|
||||
void serialize(Archive& ar) {
|
||||
serializer(ar, tpsRate, expiration);
|
||||
// Convert expiration time to a duration to avoid clock differences
|
||||
double duration = 0;
|
||||
if(!ar.isDeserializing) {
|
||||
duration = expiration - now();
|
||||
}
|
||||
|
||||
serializer(ar, tpsRate, duration);
|
||||
|
||||
if(ar.isDeserializing) {
|
||||
expiration = now() + duration;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user