You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by "suneet-s (via GitHub)" <gi...@apache.org> on 2023/10/28 14:33:17 UTC
[PR] LoadRules with 0 replicas should be treated as handoff complete (druid)
suneet-s opened a new pull request, #15274:
URL: https://github.com/apache/druid/pull/15274
### Description
Updates the `/{dataSourceName}/handoffComplete` API to treat load rules with 0 replicas as having handoff completed.
<hr>
##### Key changed/added classes in this PR
* `Rule#shouldSegmentBeLoaded`
* `LoadRule#shouldSegmentBeLoaded`
<hr>
This PR has:
- [x] been self-reviewed.
- [x] added documentation for new or modified features or behaviors.
- [ ] a release note entry in the PR description.
- [x] added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
- [x] added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
- [x] added unit tests or modified existing tests to cover new code paths, ensuring the threshold for [code coverage](https://github.com/apache/druid/blob/master/dev/code-review/code-coverage.md) is met.
- [ ] added integration tests.
- [ ] been tested in a test Druid cluster.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] LoadRules with 0 replicas should be treated as handoff complete (druid)
Posted by "AmatyaAvadhanula (via GitHub)" <gi...@apache.org>.
AmatyaAvadhanula commented on code in PR #15274:
URL: https://github.com/apache/druid/pull/15274#discussion_r1375777125
##########
server/src/main/java/org/apache/druid/server/http/DataSourcesResource.java:
##########
@@ -873,16 +872,14 @@ public Response isHandOffComplete(
final DateTime now = DateTimes.nowUtc();
// A segment that is not eligible for load will never be handed off
- boolean notEligibleForLoad = true;
+ boolean eligibleForLoad = false;
for (Rule rule : rules) {
if (rule.appliesTo(theInterval, now)) {
- if (rule instanceof LoadRule) {
- notEligibleForLoad = false;
- }
+ eligibleForLoad = rule.shouldSegmentBeLoaded();
break;
Review Comment:
Apologies, I had assumed wrongly that the check was on tier-wise basis, but a single rule has the replication factor for all the tiers.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] LoadRules with 0 replicas should be treated as handoff complete (druid)
Posted by "abhishekagarwal87 (via GitHub)" <gi...@apache.org>.
abhishekagarwal87 commented on code in PR #15274:
URL: https://github.com/apache/druid/pull/15274#discussion_r1375758542
##########
server/src/main/java/org/apache/druid/server/http/DataSourcesResource.java:
##########
@@ -873,16 +872,14 @@ public Response isHandOffComplete(
final DateTime now = DateTimes.nowUtc();
// A segment that is not eligible for load will never be handed off
- boolean notEligibleForLoad = true;
+ boolean eligibleForLoad = false;
for (Rule rule : rules) {
if (rule.appliesTo(theInterval, now)) {
- if (rule instanceof LoadRule) {
- notEligibleForLoad = false;
- }
+ eligibleForLoad = rule.shouldSegmentBeLoaded();
break;
Review Comment:
rules are applied in sequence so if the first rule is a 0-replica rule, wouldn't coordinator just stop there? A 0-replica rule must come after a 2-replica rule. that's how most load/drop rules work unless something recently changed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] LoadRules with 0 replicas should be treated as handoff complete (druid)
Posted by "AmatyaAvadhanula (via GitHub)" <gi...@apache.org>.
AmatyaAvadhanula commented on code in PR #15274:
URL: https://github.com/apache/druid/pull/15274#discussion_r1375663098
##########
server/src/main/java/org/apache/druid/server/http/DataSourcesResource.java:
##########
@@ -873,16 +872,14 @@ public Response isHandOffComplete(
final DateTime now = DateTimes.nowUtc();
// A segment that is not eligible for load will never be handed off
- boolean notEligibleForLoad = true;
+ boolean eligibleForLoad = false;
for (Rule rule : rules) {
if (rule.appliesTo(theInterval, now)) {
- if (rule instanceof LoadRule) {
- notEligibleForLoad = false;
- }
+ eligibleForLoad = rule.shouldSegmentBeLoaded();
break;
Review Comment:
I don't think we should break anymore if there are multiple rules that apply.
Suppose the first rule is 0-replica rule, and the second is a 2-replica rule for a different tier, this implementation might break saying that `eligibleForLoad = false`, but it should have been true and waited for handoff
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] LoadRules with 0 replicas should be treated as handoff complete (druid)
Posted by "suneet-s (via GitHub)" <gi...@apache.org>.
suneet-s commented on code in PR #15274:
URL: https://github.com/apache/druid/pull/15274#discussion_r1376237162
##########
server/src/main/java/org/apache/druid/server/coordinator/rules/LoadRule.java:
##########
@@ -86,10 +108,17 @@ private static void validateTieredReplicants(final Map<String, Integer> tieredRe
{
for (Map.Entry<String, Integer> entry : tieredReplicants.entrySet()) {
if (entry.getValue() == null) {
- throw InvalidInput.exception("Invalid number of replicas for tier [%s]. Value must not be null.", entry.getKey());
+ throw InvalidInput.exception(
+ "Invalid number of replicas for tier [%s]. Value must not be null.",
+ entry.getKey()
+ );
}
if (entry.getValue() < 0) {
- throw InvalidInput.exception("Invalid number of replicas for tier [%s]. Value [%d] must be positive.", entry.getKey(), entry.getValue());
+ throw InvalidInput.exception(
+ "Invalid number of replicas for tier [%s]. Value [%d] must be positive.",
+ entry.getKey(),
+ entry.getValue()
+ );
Review Comment:
Only formatting changes in this function
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] LoadRules with 0 replicas should be treated as handoff complete (druid)
Posted by "suneet-s (via GitHub)" <gi...@apache.org>.
suneet-s commented on PR #15274:
URL: https://github.com/apache/druid/pull/15274#issuecomment-1785742041
Thanks for the reviews @abhishekagarwal87 and @AmatyaAvadhanula !
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] LoadRules with 0 replicas should be treated as handoff complete (druid)
Posted by "abhishekagarwal87 (via GitHub)" <gi...@apache.org>.
abhishekagarwal87 commented on code in PR #15274:
URL: https://github.com/apache/druid/pull/15274#discussion_r1375660841
##########
server/src/main/java/org/apache/druid/server/http/DataSourcesResource.java:
##########
@@ -873,16 +872,14 @@ public Response isHandOffComplete(
final DateTime now = DateTimes.nowUtc();
// A segment that is not eligible for load will never be handed off
- boolean notEligibleForLoad = true;
+ boolean eligibleForLoad = false;
for (Rule rule : rules) {
if (rule.appliesTo(theInterval, now)) {
- if (rule instanceof LoadRule) {
- notEligibleForLoad = false;
- }
+ eligibleForLoad = rule.shouldSegmentBeLoaded();
Review Comment:
```suggestion
if (rule instanceof LoadRule) {
eligibleForLoad = ((LoadRule) rule).shouldSegmentBeLoaded();
}
```
##########
server/src/main/java/org/apache/druid/server/coordinator/rules/Rule.java:
##########
@@ -50,4 +50,12 @@ public interface Rule
boolean appliesTo(Interval interval, DateTime referenceTimestamp);
void run(DataSegment segment, SegmentActionHandler segmentHandler);
+
+ /**
+ * @return Whether a segment that matches this rule needs to be loaded on a tier.
+ */
+ default boolean shouldSegmentBeLoaded()
+ {
+ return false;
+ }
Review Comment:
This method is not really needed and could be left in LoadRule itself. In `DataSourceResource`, you can ask cast the rule to `rule` to `LoadRule` and then call `shouldSegmentBeLoaded`.
##########
server/src/main/java/org/apache/druid/server/coordinator/rules/Rule.java:
##########
@@ -50,4 +50,12 @@ public interface Rule
boolean appliesTo(Interval interval, DateTime referenceTimestamp);
void run(DataSegment segment, SegmentActionHandler segmentHandler);
+
+ /**
+ * @return Whether a segment that matches this rule needs to be loaded on a tier.
+ */
+ default boolean shouldSegmentBeLoaded()
+ {
+ return false;
+ }
Review Comment:
can you also add a comment that this method can be used in making handoff decisions?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] LoadRules with 0 replicas should be treated as handoff complete (druid)
Posted by "suneet-s (via GitHub)" <gi...@apache.org>.
suneet-s merged PR #15274:
URL: https://github.com/apache/druid/pull/15274
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org