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

Pipeline: use notify instead of polling for AggregateRestoreSourceOp #9082

Merged
merged 6 commits into from
Aug 28, 2024

Conversation

SeaRise
Copy link
Contributor

@SeaRise SeaRise commented May 23, 2024

What problem does this PR solve?

Issue Number: ref #8869

Problem Summary:

What is changed and how it works?


Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

None

@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 23, 2024
@SeaRise
Copy link
Contributor Author

SeaRise commented May 23, 2024

/cc @windtalker @gengliqi

@ti-chi-bot ti-chi-bot bot requested review from gengliqi and windtalker May 23, 2024 10:55
@SeaRise SeaRise requested a review from windtalker June 5, 2024 02:41
@@ -66,7 +82,7 @@ void SharedSpilledBucketDataLoader::storeBucketData()
RUNTIME_CHECK(status == SharedLoaderStatus::loading);

// Although the status will always stay at `SharedLoaderStatus::loading`, but because the query has stopped, it doesn't matter.
if unlikely (exec_context.isCancelled())
if (checkCancelled())
Copy link
Contributor

Choose a reason for hiding this comment

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

Why SharedQuery and ResultQueue need to be cancelled explicitly in PipelineExecutorContext::cancel, but this don't need to be cancelled in PipelineExecutorContext::cancel?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because it will not be stuck forever, when the query is canceled, checkCancel will always be called, because wait_for_notify must be because the queue is empty. When the queue is empty, it will trigger an asynchronous load bucket event, and the load bucket event will call checkCancel.

Copy link
Contributor

Choose a reason for hiding this comment

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

If trigger an asynchronous load bucket event fails, will it still work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, Event::finishImpl is always called, regardless of failure or cancellation

void LoadBucketEvent::finishImpl()
{
assert(loader);
loader->storeBucketData();
loader.reset();

Copy link
Contributor

Choose a reason for hiding this comment

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

OK. I want to confirm another unrelated question here, why WorkQueue in this pr don't need to be cancelled explicitly in PipelineExecutorContext::cancel?

Copy link
Contributor

Choose a reason for hiding this comment

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

When query meet error, the storage layer is not informed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, the storage layer is not explicitly canceled.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

However, the query will not be stuck, because the storage layer will continuously generate blocks, which will trigger checkCancel, thus ending the query.

Copy link
Contributor

Choose a reason for hiding this comment

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

Storage layer generate block => pipeline task is notified and finishes since it found the query is cancelled => ~UnorderedSourceOp() is called, and in side ~UnorderedSourceOp(), it will call task_pool->decreaseUnorderedInputStreamRefCount(), which eventually stop the storage read?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Storage layer generate block => pipeline task is notified and finishes since it found the query is cancelled => ~UnorderedSourceOp() is called, and in side ~UnorderedSourceOp(), it will call task_pool->decreaseUnorderedInputStreamRefCount(), which eventually stop the storage read?

yes

@SeaRise SeaRise requested review from windtalker July 25, 2024 08:13
Copy link
Contributor

@windtalker windtalker left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Jul 25, 2024
Copy link
Contributor

@gengliqi gengliqi left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

ti-chi-bot bot commented Aug 28, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gengliqi, windtalker

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [gengliqi,windtalker]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Aug 28, 2024
Copy link
Contributor

ti-chi-bot bot commented Aug 28, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-07-25 09:11:55.150323462 +0000 UTC m=+1122737.141264929: ☑️ agreed by windtalker.
  • 2024-08-28 11:18:50.169920971 +0000 UTC m=+955525.304371092: ☑️ agreed by gengliqi.

@ti-chi-bot ti-chi-bot bot merged commit 637501a into pingcap:master Aug 28, 2024
5 checks passed
@SeaRise SeaRise deleted the notify_for_agg_restore branch August 29, 2024 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants