Skip to content

Conversation

@etschannen
Copy link
Contributor

No description provided.

for(int i = 0; i < oldLogRouters.size(); i++) {
result.oldLogRouters.push_back(oldLogRouters[i].interf);
if(req.maxOldLogRouters > 0) {
auto oldLogRouters = tlogs;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be assuming that req.maxOldLogRouters is less than or equal to tlogs.size+1. Either that, or we're just ignoring maxOldLogRouters.

Can we make that an ASSERT if that's the case?

Copy link
Contributor Author

@etschannen etschannen Jan 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code is already written so that it can recruit multiple log routers on the same worker, so the maxOldLogRouters was a suggested maximum number of workers, but returning fewer is okay

Copy link
Contributor

@ajbeamon ajbeamon Jan 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My concern was the opposite -- namely what if maxOldLogRouters is smaller than the number of logs. If such a thing were possible, this would result in there being more old log routers than the max.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking at the code, the list of workers does not determine the number of log routers, so in that case it would just ignore the additional interfaces

}
if(foundCC) {
result.oldLogRouters.push_back(oldLogRouters.back().interf);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this logic means that we will always have 1 fewer old log router than tlogs (except when there's only 1)? Is there any reason not to use all of the tlogs when none of them are the cluster controller?

If what's written is the intent, the else block could be simplified to something like:

for(int i = 0; i < oldLogRouters.size() && result.oldRouters.size() < oldLogRouters.size() - 1; ++i) {
	if(oldLogRouters[i].interf.locality.processId() != clusterControllerProcessId) {
		result.oldLogRouters.push_back(oldLogRouters[i].interf);
	}
}

for(auto& it : rep.oldLogRouters) {
self->db.requiredAddresses.insert(it.address());
if( it.tLog.getEndpoint().addresses.secondaryAddress.present() ) self->db.requiredAddresses.insert(it.tLog.getEndpoint().addresses.secondaryAddress.get());
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this loop is written a bunch of times, it might be a good candidate for extracting into a function.

@etschannen etschannen merged commit 032797c into apple:release-6.2 Jan 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants