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

feat: Generate Idle Watermark if the source is idling #1385

Merged
merged 56 commits into from
Dec 7, 2023
Merged

Conversation

chandankumar4
Copy link
Contributor

@chandankumar4 chandankumar4 commented Nov 23, 2023

Explain what this PR does.

  • Generate the idle Watermark if the source is idling

Fixes #633

Example Pipeline to test the changes:

apiVersion: numaflow.numaproj.io/v1alpha1
kind: Pipeline
metadata:
  name: idle-source
spec:
  watermark:
    idleSource:
      threshold: 5s
      incrementBy: 5s
      stepInterval: 5s
  limits:
    readBatchSize: 50
  vertices:
    - name: in
      scale:
        min: 2
      source:
        http: {}
    - name: atoi
      scale:
        min: 1
      udf:
        container:
          # Tell the input number is even or odd, see https://github.com/numaproj/numaflow-go/tree/main/pkg/mapper/examples/even_odd
          image: quay.io/numaio/numaflow-go/map-even-odd:v0.5.0
    - name: compute-sum
      partitions: 2
      udf:
        container:
          # Compute the sum, see https://github.com/numaproj/numaflow-go/tree/main/pkg/reducer/examples/sum
          image: quay.io/numaio/numaflow-go/reduce-sum:v0.5.0
        groupBy:
          window:
            fixed:
              length: 10s
          keyed: true
          storage:
            persistentVolumeClaim:
              volumeSize: 10Gi
              accessMode: ReadWriteOnce
    - name: sink
      scale:
        min: 1
      sink:
        udsink:
          container:
            # A redis sink for e2e testing, see https://github.com/numaproj/numaflow-sinks/tree/main/redis-e2e-test-sink
            image: quay.io/numaio/numaflow-sink/redis-e2e-test-sink:v0.5.0
  edges:
    - from: in
      to: atoi
    - from: atoi
      to: compute-sum
    - from: compute-sum
      to: sink

Note:
This will not work in below case:

  • In case of Kafka with 12 partition and 6 partition is assigned to one pod and rest 6 to another, now If only 3 of them is receiving the data out of 6 partition.

yhl25 and others added 6 commits November 23, 2023 22:08
Signed-off-by: Yashash H L <[email protected]>
Signed-off-by: chandankumar4 <[email protected]>
Signed-off-by: chandankumar4 <[email protected]>
Signed-off-by: chandankumar4 <[email protected]>
Signed-off-by: chandankumar4 <[email protected]>
@vigith vigith changed the title chore!: Generate Idle Watermark if the source is idling. Fixes #633 feat: Generate Idle Watermark if the source is idling Nov 23, 2023
pkg/sources/forward/data_forward.go Outdated Show resolved Hide resolved
pkg/sources/udsource/user_defined_source.go Outdated Show resolved Hide resolved
pkg/watermark/fetch/edge_fetcher_set.go Outdated Show resolved Hide resolved
Signed-off-by: chandankumar4 <[email protected]>
pkg/apis/numaflow/v1alpha1/pipeline_types.go Outdated Show resolved Hide resolved
pkg/apis/numaflow/v1alpha1/pipeline_types.go Outdated Show resolved Hide resolved
pkg/sources/forward/data_forward.go Outdated Show resolved Hide resolved
pkg/sources/forward/data_forward.go Outdated Show resolved Hide resolved
pkg/sources/forward/data_forward.go Outdated Show resolved Hide resolved
pkg/sources/forward/data_forward.go Outdated Show resolved Hide resolved
pkg/sources/forward/data_forward.go Outdated Show resolved Hide resolved
pkg/sources/forward/data_forward.go Outdated Show resolved Hide resolved
pkg/apis/numaflow/v1alpha1/pipeline_types.go Outdated Show resolved Hide resolved
pkg/apis/numaflow/v1alpha1/pipeline_types.go Outdated Show resolved Hide resolved
pkg/apis/numaflow/v1alpha1/pipeline_types.go Outdated Show resolved Hide resolved
pkg/apis/numaflow/v1alpha1/pipeline_types.go Outdated Show resolved Hide resolved
Signed-off-by: chandankumar4 <[email protected]>
@chandankumar4 chandankumar4 marked this pull request as ready for review November 27, 2023 12:50
Signed-off-by: chandankumar4 <[email protected]>
chandankumar4 and others added 5 commits November 28, 2023 00:09
Signed-off-by: chandankumar4 <[email protected]>
Signed-off-by: chandankumar4 <[email protected]>
Signed-off-by: Yashash H L <[email protected]>
Signed-off-by: chandankumar4 <[email protected]>
KeranYang

This comment was marked as resolved.

chandankumar4 and others added 6 commits December 5, 2023 15:10
Comment on lines 8 to 10
threshold: 5s
incrementBy: 3s
stepInterval: 2s
Copy link
Member

Choose a reason for hiding this comment

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

Can we add some comments on these numbers on how they are used to test source idling? The comment should make it clear why removing these configurations will break the test.

Copy link
Member

Choose a reason for hiding this comment

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

I am un-resolving this one. We configured the idle source, updated the simple keyed reduce test with a new start time and new wait time before sending next batch.

I have a hard time understanding how this test works in terms of verifying idle source works. Can we write some comments on why this test is testing the source idling functionality? How these numbers 5s, 3s, 2s, startTime := 100, time.Sleep(10 * time.Millisecond)andWithTimeout(120*time.Second)` work together to achieve idle source test?

Copy link
Member

Choose a reason for hiding this comment

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

@vigith vigith marked this pull request as ready for review December 6, 2023 03:04
Copy link
Member

Choose a reason for hiding this comment

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

can we add a unit test of idle handler?

return 0
// Partitions returns the partitions from which the source is reading.
func (r *kafkaSource) Partitions() []int32 {
for topic, partitions := range r.handler.sess.Claims() {
Copy link
Member

Choose a reason for hiding this comment

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

please make sure this doesn't involve a n/w call. i am quite sure it wouldn't.

Comment on lines +136 to +144
readMessages, err := u.sourceApplier.ApplyReadFn(ctx, count, u.readTimeout)
if err != nil {
return nil, err
}
for _, msg := range readMessages {
if _, ok := u.partitions[msg.ReadOffset.PartitionIdx()]; !ok {
u.partitions[msg.ReadOffset.PartitionIdx()] = struct{}{}
}
}
Copy link
Member

Choose a reason for hiding this comment

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

this is not right, we only append by never remove. we will have to ask users to add Partitions() to ud-source interface.

@KeranYang WDYT?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

@KeranYang KeranYang Dec 6, 2023

Choose a reason for hiding this comment

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

I agree this is not right. With this change we now have two sources of truth on how many partitions a source has. One is the read batch and the other is the source Partitions() interface. Should stick with the second one.

The removing part can be tricky because if we remove a certain partition, we also need to remove the corresponding watermark KV store etc. We can look into details as part of issue 1405 that you created.

sourcePublishWM := NewPublish(sp.ctx, processorEntity, sp.srcPublishWMStores, 1, IsSource(), WithDelay(sp.opts.delay))
sp.sourcePublishWMs[sp.opts.defaultPartitionIdx] = sourcePublishWM
}

Copy link
Member

Choose a reason for hiding this comment

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

please document else branch

Copy link
Member

@vigith vigith left a comment

Choose a reason for hiding this comment

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

need few changes as discussed.

vigith and others added 3 commits December 5, 2023 19:49
Signed-off-by: Vigith Maurice <[email protected]>
Signed-off-by: Yashash H L <[email protected]>
Signed-off-by: chandankumar4 <[email protected]>
Copy link
Member

@KeranYang KeranYang 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 only one minor comment open. Approving.

Signed-off-by: Vigith Maurice <[email protected]>
@vigith vigith enabled auto-merge (squash) December 7, 2023 03:03
@vigith vigith merged commit 0db9cd1 into main Dec 7, 2023
18 of 19 checks passed
@vigith vigith deleted the idle-source branch December 7, 2023 03:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Idle Source
5 participants