Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
both the leader and the proxy (peon) monitor will call this method when handling a pg-created. how about calling
mon->no_reply(op)
inOSDMonitor::prepare_pg_created()
andOSDMonitor::prepare_beacon()
instead ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the function itself even mentions (at the bottom) we "always forward" to the leader, then I agree with @tchaikov that we should have this only on the prepare functions (which are essentially only called on the leader), for both the pg create and the osd beacon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I considered it but actually don’t like that:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't follow you.
mon->no_reply(op)
will reply the proxy mon, which will in turn remove the the routed request from itsrouted_requests
map. if there will be any future message which we don't need reply to the party who sent the request. we should callmon->no_reply(op)
in the leader mon.yeah, i did notice the error case handling in the preprocess. there are two cases
routed_requests
map, and the message's life cycle is managed by MonOpRequestRef, which is able to take care of itself just fine, evenmon->no_reply()
does nothing in this case other thanmark_event("no_reply")
.routed_requests
map. ifmon->no_reply(op)
is called inOSDMonitor::prepare_pg_created()
by the leader, the peon who forwarded the request will get an MRoute message. so no leak is caused.well, i'd say it's a subjective assertion. my point is that
no_reply()
only takes effect on leader, and we only do prepare on leader. if we can reach a consensus on this, probably it would make more sense to callmon->no_reply()
in the prepare methods.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean that we may change the code in the future, so that no_reply() does something on follower monitors as well. In which case we'd have to change them.
And again, you're right that with the current error cases in preprocess, they will not bail out on the leader if the message was forwarded.
But the cost of calling no_reply() in preprocess is...very low. And putting it at the top of that function, instead of down in the bottom of the call stack where only the leader can see it, is a very simple way to practice defensive programming so that we don't leak forwarded messages due to changes in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay, but i'd prefer reasoning based on what we have instead of the hypotheses.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is reasoning based on what we have. It is simple and obviously correct. You are trying to optimize away a function call on a path that involves passing multiple messages over the wire, because you have chased down at least three different things that must be true for that optimization to be safe and determined that they are. It’s a false economy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eh, this kind of blew out of proportion; but given @gregsfortytwo's arguments a wee-bit above, I kinda agree with him. We are losing nothing by marking the op no_reply() early in preprocess, afaict, and we are ensuring that the proxy mon gets to drop its routed request as soon as possible. The only thing that tickles me the wrong way, but it's objectively irrelevant I think, is that we are replying to a message (in this case to the proxy mon) before the message has been handled, which is not the way we typically do things in the monitor and likely why we have been preferring replying at a later stage in the function call instead of at the beginning.