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

chore: fix watermark components ownership #963

Merged
merged 9 commits into from
Aug 19, 2023
Merged

chore: fix watermark components ownership #963

merged 9 commits into from
Aug 19, 2023

Conversation

yhl25
Copy link
Contributor

@yhl25 yhl25 commented Aug 18, 2023

related to #900

  • publisher shouldn't close the store, it should just delete its key from the store, since it doesn't own it and in some cases, stores will be shared across publishers(for example Kafka source)
  • for source, publishers should be closed inside the forwarder, since creation also happens inside the forwarder
  • for the map, reduce and sink publishers and fetchers should be closed outside the forwarder because they don't own them and they are shared when there are multiple partitions
  • introduced BuildProcessorManagers, BuildToVertexWatermarkStores and BuildPublishersFromStores helper functions
  • removed io.Closer from Fetcher and UXFetcher interface.

also fixes #962

Signed-off-by: Yashash H L <yashashhl25@gmail.com>
@yhl25 yhl25 requested a review from jy4096 August 18, 2023 02:57
Signed-off-by: Yashash H L <yashashhl25@gmail.com>
Signed-off-by: Yashash H L <yashashhl25@gmail.com>
// close the wm stores, since the publisher and fetcher are closed
// since we created the stores, we can close them
for _, wmStore := range wmStores {
wmStore.HeartbeatStore().Close()
Copy link
Member

Choose a reason for hiding this comment

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

Add a Close() function to WatermarkStore interface ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

names := u.VertexInstance.Vertex.GetToBuffers()
if u.VertexInstance.Vertex.IsASink() {
// Sink has no to buffers, we use the vertex name as the buffer writer name.
names = append(names, u.VertexInstance.Vertex.Spec.Name)
Copy link
Member

Choose a reason for hiding this comment

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

Already know it's a sink, then the line above is not needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

log.Info("SIGTERM, exiting...")
wg.Wait()

// close the watermark fetcher and publisher since we created them
err = fetchWatermark.Close()
if err != nil {
log.Error("Failed to close the watermark fetcher", zap.Error(err))
Copy link
Member

Choose a reason for hiding this comment

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

log.Errorw()

@@ -214,18 +245,29 @@ func (u *MapUDFProcessor) Start(ctx context.Context) error {
// wait for all the forwarders to exit
finalWg.Wait()

// Close the watermark fetcher and publisher
// close the watermark fetcher and publisher since we created them
err = fetchWatermark.Close()
if err != nil {
log.Error("Failed to close the watermark fetcher", zap.Error(err))
Copy link
Member

Choose a reason for hiding this comment

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

Errorw()

pkg/watermark/fetch/edge_fetcher.go Show resolved Hide resolved
Signed-off-by: Yashash H L <yashashhl25@gmail.com>
Signed-off-by: Yashash H L <yashashhl25@gmail.com>
@yhl25 yhl25 requested a review from whynowy August 18, 2023 07:43
@yhl25 yhl25 marked this pull request as ready for review August 18, 2023 07:43
@yhl25 yhl25 requested a review from vigith as a code owner August 18, 2023 07:43
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.

Thank you very much for making this change. The ownership among fetcher, publisher, processor manger and kv stores are much clearer now. +1

pkg/isbsvc/jetstream_service.go Show resolved Hide resolved
Signed-off-by: Vigith Maurice <vigith@gmail.com>
Signed-off-by: Vigith Maurice <vigith@gmail.com>
for _, publisher := range publishWatermark {
err = publisher.Close()
if err != nil {
log.Error("Failed to close the watermark publisher", zap.Error(err))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
log.Error("Failed to close the watermark publisher", zap.Error(err))
log.Errorw("Failed to close the watermark publisher", zap.Error(err))

return err
if u.VertexInstance.Vertex.Spec.Watermark.Disabled {
names := u.VertexInstance.Vertex.GetToBuffers()
if u.VertexInstance.Vertex.IsASink() {
Copy link
Member

Choose a reason for hiding this comment

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

Remove it.

return err
if u.VertexInstance.Vertex.Spec.Watermark.Disabled {
names := u.VertexInstance.Vertex.GetToBuffers()
if u.VertexInstance.Vertex.IsASink() {
Copy link
Member

Choose a reason for hiding this comment

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

Remove it.

if u.VertexInstance.Vertex.Spec.Watermark.Disabled {
names := u.VertexInstance.Vertex.GetToBuffers()
// sink has no to buffers, so we use the vertex name to publish the watermark
names = append(names, u.VertexInstance.Vertex.Spec.Name)
Copy link
Member

Choose a reason for hiding this comment

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

names := []string{u.VertexInstance.Vertex.Spec.Name}

if err != nil {
return err
}

// build publisher stores for source (we publish twice for source)
Copy link
Contributor

Choose a reason for hiding this comment

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

could you add a comment here to explain why we need two sets of publisher stores?..

Signed-off-by: Derek Wang <whynowy@gmail.com>
.
Signed-off-by: Derek Wang <whynowy@gmail.com>
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.

We need to rename these, using BuildProcessorManagers to build fetchers, and BuildToVertexWatermarkStores to build publishers does not make sense.

The code should be self-documenting, as of now, it is quite difficult for a casual reader to understand the code.

Fetch

processorManagers, err = jetstream.BuildProcessorManagers(ctx, u.VertexInstance, natsClientPool.NextAvailableClient())

// create watermark fetcher using processor managers
fetchWatermark = fetch.NewEdgeFetcherSet(ctx, u.VertexInstance, processorManagers)

Publish

// create watermark stores
wmStores, err = jetstream.BuildToVertexWatermarkStores(ctx, u.VertexInstance, natsClientPool.NextAvailableClient())


// create watermark publisher using watermark stores
publishWatermark = jetstream.BuildPublishersFromStores(ctx, u.VertexInstance, wmStores)

readers, writers, err = buildJetStreamBufferIO(ctx, u.VertexInstance, natsClientPool)

@vigith vigith merged commit ed53342 into main Aug 19, 2023
15 checks passed
@vigith vigith deleted the wm-store branch August 19, 2023 00:35
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.

flaky test: TestNewDataForward/batch_forward_basic
5 participants