Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

supervisor: make rejection periods work with stopTasksCount #17442

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

adithyachakilam
Copy link
Contributor

@adithyachakilam adithyachakilam commented Nov 3, 2024

Description

In cases where stopTasksCount is configured which makes streaming tasks run much longer (in some cases) than the configured task duration, early/late rejection periods are not correctly implemented since they are configured during the task startup time in IOConfig. Instead, this PR propagates updates the min/max times once every task duration.


Key changed/added classes in this PR
  • SeekableStreamIndexTaskRunner
  • SeekableStreamIndexTaskIOConfig

This PR has:

  • been self-reviewed.
  • added documentation for new or modified features or behaviors.
  • a release note entry in the PR description.
  • added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
  • added or updated version, license, or notice information in licenses.yaml
  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.
  • added integration tests.
  • been tested in a test Druid cluster.

Copy link
Contributor

@suneet-s suneet-s left a comment

Choose a reason for hiding this comment

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

This implementation of refreshing the min / max times every 10 min is a change in behavior, so I think the person submitting the supervisor spec needs to opt in to this new behavior which doesn't appear possible in the current approach.

An alternative approach to consider is to update the IOConfig to include a "refresh interval" field that defaults to infinity that would refresh the min / max times in the IOConfig.

The tasks could then update their min / max times every duration just by adding the refresh interval so we don't need to worry about clock skew across the peons.

Since this patch is meant to just deal with stopTaskCount - have you considered refreshing the min / max times every task duration to mimic the existing behavior if stopTaskCount was not set (aka every task duration the min/max times across all peons are updated)

Comment on lines 53 to 54
@JsonProperty("lateMessageRejectionPeriod") Duration lateMessageRejectionPeriod,
@JsonProperty("earlyMessageRejectionPeriod") Duration earlyMessageRejectionPeriod,
Copy link
Contributor

Choose a reason for hiding this comment

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

These new fields need to be in addition to the old fields to ensure a newer version of the overlord works with older versions of the indexing tasks. But more importantly, in the case of a rollback - an older overlord needs to work with a newer version of indexing services

@adithyachakilam
Copy link
Contributor Author

@suneet-s Thanks for the review, I've changed the patch to just update the min/max times once every task duration. So this also avoids all those version problems.

SeekableStreamStartSequenceNumbers<String, String> sequenceNumbers = Mockito.mock(SeekableStreamStartSequenceNumbers.class);
SeekableStreamEndSequenceNumbers<String, String> endSequenceNumbers = Mockito.mock(SeekableStreamEndSequenceNumbers.class);

DateTime now = DateTimes.nowUtc();

Check notice

Code scanning / CodeQL

Unread local variable Note test

Variable 'DateTime now' is never read.
@adithyachakilam adithyachakilam changed the title supervisor: propagate rejection periods to tasks supervisor: make rejection periods work with stopTasksCount Nov 5, 2024
Copy link
Contributor

@suneet-s suneet-s left a comment

Choose a reason for hiding this comment

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

I have not reviewed the tests yet.

For this change, we should also include docs for what this new parameter is in the IOConfig

@@ -51,7 +53,8 @@ public SeekableStreamIndexTaskIOConfig(
final Boolean useTransaction,
final DateTime minimumMessageTime,
final DateTime maximumMessageTime,
@Nullable final InputFormat inputFormat
@Nullable final InputFormat inputFormat,
@Nullable final Duration taskDuration // can be null for backward compabitility
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there an advantage to using Duration? Would it be simpler to pass this in as a long of minutes

Suggested change
@Nullable final Duration taskDuration // can be null for backward compabitility
@Nullable final Long refreshRejectionPeriodsInMinutes // can be null for backward compabitility

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think its good to have Duration and no need to convert back and forth and also confusion of adding mins to the variable. You think there are any issues with the schema deserializing ? (I see at least Period used, maybe we can switch to it if so )

Also, regarding variable name change, Do you think there would be a usecase of user editing it to a different value ? I would prefer to use taskDuration so that no one touches and would also avoid the need for docs (Also, I dont find this documented anywhere, can you point me to the file ?)

private void addTaskDurationToMinMaxTimes()
{
if (minMessageTime.isPresent()) {
minMessageTime = Optional.of(minMessageTime.get()
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it ok that intelliJ is warning that this is an unsafe update of a volatile variable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah its ok.

Its complaining because we are using the same variable to update the value but we only do it once every taskDuration. If it was done more frequently we should have used atomic references.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants