Serialize throttle limits with expiration expressed as a duration to avoid clock differences.

This commit is contained in:
A.J. Beamon 2020-04-22 14:15:35 -07:00
parent d2504c08c3
commit ede69c5141
2 changed files with 16 additions and 3 deletions

View File

@ -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();
}
};

View File

@ -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;
}
}
};