Merge pull request #5272 from sbodagala/version-vector-prototype

Version vector prototype: Tweak the logic that populates CommitBatchContext::written_tags
This commit is contained in:
Dan Lambright 2021-08-02 14:50:03 -06:00 committed by GitHub
commit 2d5e265e76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 5 deletions

View File

@ -74,6 +74,8 @@ struct Tag {
int toTagDataIndex() const { return locality >= 0 ? 2 * locality : 1 - (2 * locality); }
bool isNonPrimaryTLogType() const { return locality < 0; }
std::string toString() const { return format("%d:%d", locality, id); }
template <class Ar>

View File

@ -965,7 +965,6 @@ ACTOR Future<Void> assignMutationsToStorageServers(CommitBatchContext* self) {
if (pProxyCommitData->cacheInfo[m.param1]) {
self->toCommit.addTag(cacheTag);
}
self->toCommit.saveTags(self->writtenTags);
self->toCommit.writeTypedMessage(m);
self->toCommit.saveLocations(self->writtenTLogs);
} else if (m.type == MutationRef::ClearRange) {
@ -1023,7 +1022,6 @@ ACTOR Future<Void> assignMutationsToStorageServers(CommitBatchContext* self) {
if (pProxyCommitData->needsCacheTag(clearRange)) {
self->toCommit.addTag(cacheTag);
}
self->toCommit.saveTags(self->writtenTags);
self->toCommit.writeTypedMessage(m);
self->toCommit.saveLocations(self->writtenTLogs);
} else {
@ -1115,6 +1113,8 @@ ACTOR Future<Void> postResolution(CommitBatchContext* self) {
// Second pass
wait(assignMutationsToStorageServers(self));
self->toCommit.saveTags(self->writtenTags);
// Obtain previous committed versions for each affected tlog from sequencer
if (SERVER_KNOBS->ENABLE_VERSION_VECTOR) {
wait(getTPCV(self));

View File

@ -996,9 +996,13 @@ struct LogPushData : NonCopyable {
writtenLocations.clear();
}
// copy next_message_tags into given set
void saveTags(std::set<Tag>& writtenTags) {
writtenTags.insert(next_message_tags.begin(), next_message_tags.end());
// copy written_tags, after filtering, into given set
void saveTags(std::set<Tag>& filteredTags) const {
for (const auto& tag : written_tags) {
if (!tag.isNonPrimaryTLogType()) {
filteredTags.insert(tag);
}
}
}
// store tlogs as represented by index
@ -1017,6 +1021,7 @@ struct LogPushData : NonCopyable {
}
msg_locations.clear();
logSystem->getPushLocations(prev_tags, msg_locations);
written_tags.insert(next_message_tags.begin(), next_message_tags.end());
next_message_tags.clear();
}
uint32_t subseq = this->subsequence++;
@ -1095,6 +1100,7 @@ struct LogPushData : NonCopyable {
wr.serializeBytes((uint8_t*)from.getData() + firstOffset, firstLength);
}
}
written_tags.insert(next_message_tags.begin(), next_message_tags.end());
next_message_tags.clear();
}
@ -1104,6 +1110,7 @@ private:
Reference<ILogSystem> logSystem;
std::vector<Tag> next_message_tags;
std::vector<Tag> prev_tags;
std::set<Tag> written_tags;
std::vector<BinaryWriter> messagesWriter;
std::vector<int> msg_locations;
// Stores message locations that have had span information written to them