Skip to content

Adds Idle feature to SeekableStreamSupervisor for inactive stream - #13144

Merged
abhishekagarwal87 merged 31 commits into
apache:masterfrom
tejaswini-imply:feature-idle_supervisor
Oct 12, 2022
Merged

abhishekagarwal87 merged 31 commits into
apache:masterfrom
tejaswini-imply:feature-idle_supervisor

Conversation

@tejaswini-imply

@tejaswini-imply tejaswini-imply commented Sep 26, 2022 •

Copy link
Copy Markdown
Member

Description

When a Kafka stream becomes inactive, i.e., no new data arrives, and all existing data is read, there is no need for Supervisor to create new indexing tasks.

  • Supervisor fetches current offsets every tuningConfig.offsetFetchPeriod (default - 30 sec) and compares them with latest offsets (fetched every ioConfig.period (default - 30 sec)) for lags. If the stream is inactive for dataSchema.ioConfig.idleConfig.inactiveAfterMillis, then supervisor state is turned to IDLE. (See conf section)
  • When Supervisor is in idle state it just doesn't create any new indexing tasks.
  • This temporary IDLE state is cleared when supervisor is restarted e.g. updated spec.
  • While the supervisor is in this temporary idle state, Supervisor will continue to check for any changes in the latest offsets (or if lag is > 0). If activity in the stream is detected again, then supervisor will come out of its IDLE state into RUNNING and resume creating indexing tasks.

Please note the initial delay before new data is ingested from when new data enters into the stream is the frequency of offsets fetch (30 sec) + initial warmup time to create new indexing tasks.

How current offsets fetching work:

Current offsets are fetched from running, publishing tasks for the partitions available and for the rest of the partitions from the metadata storage.

Configuration changes

  • dataSchema.ioConfig.idleConfig
    • enabled - If true Supervisor goes into idle state when stream is inactive. The default value is false.
    • inactiveAfterMillis - Minimum time interval to wait until stream is considered inactive/idle. The default value is 600,000 millis.
  • Adds new State - IDLE - to Basic states of Supervisor.

Key changed/added classes in this PR
  • SeekableStreamSupervisor
  • KafkaSupervisor
  • KafkaSupervisorIOConfig
  • SupervisorStateManager
  • IdleConfig

This PR has:

  • been self-reviewed.
  • added documentation for new or modified features or behaviors.
  • 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.

@lgtm-com

lgtm-com Bot commented Sep 26, 2022

Copy link
Copy Markdown

This pull request introduces 1 alert when merging d16f8d1 into 0bfa81b - view on LGTM.com

new alerts:

  • 1 for Boxed variable is never null

@lgtm-com

lgtm-com Bot commented Sep 26, 2022

Copy link
Copy Markdown

This pull request introduces 1 alert when merging 440544e into 0bfa81b - view on LGTM.com

new alerts:

  • 1 for Boxed variable is never null

Comment thread docs/configuration/index.md Outdated
@tejaswini-imply
tejaswini-imply marked this pull request as ready for review September 30, 2022 09:43
@AmatyaAvadhanula

Copy link
Copy Markdown
Contributor

@tejaswini-imply thank you for the changes and tests.
However, ITKafkaIndexingServiceNonTransactionalParallelizedTest.testIndexDataWithIdleBehaviourEnabled seems to be failing.
Could you please set the environment to enable cluster-wide idle behaviour?

@AmatyaAvadhanula AmatyaAvadhanula left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@tejaswini-imply Thank you for the changes. LGTM

@kfaraz kfaraz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the feature, @tejaswini-imply !
I have added a bunch of comments, mostly minor style suggestions.

Around the nomenclature of the new configs, naming a config behaviour or feature seems a little redundant.
I would prefer something like:
druid.supervisor.idleWhenInactive
or druid.server.setIdleWhenInactive
and
druid.supervisor.idleWaitTimeMillis.

}

// if we're trying to switch to a healthy steady state (i.e. RUNNING or SUSPENDED) but haven't had a successful run
// if we're trying to switch to a healthy steady state (i.e. RUNNING or SUSPENDED) or IDLE state but haven't had a successful run

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think this change is applicable since IDLE doesn't count as a "healthy steady state". IIUC, the healthySteadyState can only be RUNNING or SUSPENDED, which is determined while creating this SupervisorStateManager instance.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

IDLE isn't a healthy steady state. Hence it's mentioned healthy steady state or IDLE state. Please let me know if the way it's mentioned is confusing.

@@ -0,0 +1,60 @@
{

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This spec seems pretty generic. Do we really need to add a new one for the new test or can we reuse any existing one?

Comment thread .travis.yml Outdated
Comment thread docs/development/extensions-core/kafka-supervisor-reference.md Outdated
Comment thread docs/development/extensions-core/kafka-supervisor-operations.md Outdated

@kfaraz kfaraz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Added minor comments, otherwise looks good.

"idleConfig": {
"enabled": true,
"inactiveAfterMillis": 600000
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: missing comma


import javax.annotation.Nullable;

public class IdleConfig

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please add a javadoc.

@abhishekagarwal87
abhishekagarwal87 merged commit 3e13584 into apache:master Oct 12, 2022
@abhishekagarwal87

Copy link
Copy Markdown
Contributor

Thank you @tejaswini-imply. This is going to be very useful feature.

@tejaswini-imply

Copy link
Copy Markdown
Member Author

Thanks @AmatyaAvadhanula, @kfaraz and @abhishekagarwal87 for thorough review.

@tejaswini-imply tejaswini-imply mentioned this pull request Nov 17, 2022
5 of 10 tasks
kfaraz pushed a commit that referenced this pull request Nov 17, 2022
Fixes inclusion of all stream partitions in all tasks.

The PR (Adds Idle feature to `SeekableStreamSupervisor` for inactive stream) - #13144 updates the resulting lag calculation map in `KafkaSupervisor` to include all the latest partitions from the stream to set the idle state accordingly rather than the previous way of lag calculation only for the partitions actively being read from the stream. This led to an explosion of metrics in lag reports in cases where 1000s of tasks per supervisor are present.

Changes:
- Add a new method to generate lags for only those partitions a single task is actively reading from while updating the Supervisor reports.
@kfaraz kfaraz added this to the 25.0 milestone Nov 22, 2022
riovic918data pushed a commit to riovic918data/druid that referenced this pull request Jun 12, 2026
…pache#13144)

* Idle Seekable stream supervisor changes.

* nit

* nit

* nit

* Adds unit tests

* Supervisor decides it's idle state instead of AutoScaler

* docs update

* nit

* nit

* docs update

* Adds Kafka unit test

* Adds Kafka Integration test.

* Updates travis config.

* Updates kafka-indexing-service dependencies.

* updates previous offsets snapshot & doc

* Doesn't act if supervisor is suspended.

* Fixes highest current offsets fetch bug, adds new Kafka UT tests, doc changes.

* Reverts Kinesis Supervisor idle behaviour changes.

* nit

* nit

* Corrects SeekableStreamSupervisorSpec check on idle behaviour config, adds tests.

* Fixes getHighestCurrentOffsets to fetch offsets of publishing tasks too

* Adds Kafka Supervisor UT

* Improves test coverage in druid-server

* Corrects IT override config

* Doc updates and Syntactic changes

* nit

* supervisorSpec.ioConfig.idleConfig changes
riovic918data pushed a commit to riovic918data/druid that referenced this pull request Jun 12, 2026
Fixes inclusion of all stream partitions in all tasks.

The PR (Adds Idle feature to `SeekableStreamSupervisor` for inactive stream) - apache#13144 updates the resulting lag calculation map in `KafkaSupervisor` to include all the latest partitions from the stream to set the idle state accordingly rather than the previous way of lag calculation only for the partitions actively being read from the stream. This led to an explosion of metrics in lag reports in cases where 1000s of tasks per supervisor are present.

Changes:
- Add a new method to generate lags for only those partitions a single task is actively reading from while updating the Supervisor reports.
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.

4 participants