Skip to content

Allow sources to render arbitrary dataflows - #18055

Merged
petrosagg merged 7 commits into
MaterializeInc:mainfrom
petrosagg:source-connection-render
Apr 3, 2023
Merged

petrosagg merged 7 commits into
MaterializeInc:mainfrom
petrosagg:source-connection-render

Conversation

@petrosagg

@petrosagg petrosagg commented Mar 10, 2023 •

Copy link
Copy Markdown
Contributor

Motivation

This PR defines the SourceRender trait which supersedes all the previous ways a source could be defined. Sources are now able to render arbitrary dataflows, taking advantage of multiple communicating timely operators when needed.

A lot of the auxiliary types that used to support the old traits have been removed.

Of special mention is the conversion of the Kafka source implementation to the new trait which applies a few simplifications by being smarter with how capabilities are managed.

Specifically, the operator does not downgrade its capability for every message. Instead, it exhausts all the available messages from the partitions which are emitted with the same capability but at different times (a la DD triplets) and then downgrades the capability of each partition once.

This produces a significant performance boost in the feature benchmarks:

NAME                      |    THIS     |    OTHER    |  Regression?  | 'THIS' is:
----------------------------------------------------------------------------------------------------
KafkaEnvelopeNoneBytes    |      11.524 |      12.409 |      no       | 7.1 pct   faster
KafkaUpsert               |       3.163 |       5.172 |      no       | 38.8 pct   faster
KafkaUpsertUnique         |       4.436 |       5.180 |      no       | 14.4 pct   faster

Tips for reviewer

Reviewing commit by commit is recommended. Also, definitely read the new doc comments before reading the code to understand how the new trait works.

Checklist

  • This PR has adequate test coverage / QA involvement has been duly considered.
  • This PR has an associated up-to-date design doc, is a design doc (template), or is sufficiently small to not require a design.
  • This PR evolves an existing $T ⇔ Proto$T mapping (possibly in a backwards-incompatible way) and therefore is tagged with a T-proto label.
  • If this PR will require changes to cloud orchestration, there is a companion cloud PR to account for those changes that is tagged with the release-blocker label (example).
  • This PR includes the following user-facing behavior changes:

@petrosagg
petrosagg force-pushed the source-connection-render branch 2 times, most recently from 16ffb6d to 778ac52 Compare March 14, 2023 11:20
@petrosagg
petrosagg force-pushed the source-connection-render branch 6 times, most recently from 525915c to 66434fc Compare March 27, 2023 17:45
@petrosagg
petrosagg force-pushed the source-connection-render branch 3 times, most recently from 44fc0a7 to e1c6f0a Compare March 27, 2023 20:00
@petrosagg
petrosagg marked this pull request as ready for review March 27, 2023 20:00
@petrosagg
petrosagg requested review from a team, aljoscha and guswynn March 27, 2023 20:00
@petrosagg

Copy link
Copy Markdown
Contributor Author

@philip-stoev this PR changes quite a few things in case you want to direct your attention to it

@petrosagg
petrosagg force-pushed the source-connection-render branch from e1c6f0a to 714008a Compare March 28, 2023 10:39

@guswynn guswynn 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.

Amazing! This is looking so much better! I just have a few comments and questions! Also, I feel like keeping the OffsetCommitter trait, but its your call!

Comment thread src/storage/src/source/types.rs Resolved
Comment thread src/storage/src/render/mod.rs Resolved
Comment thread src/storage/src/render/mod.rs Resolved
Comment thread src/storage/src/source/types.rs Resolved
Comment thread src/storage/src/source/types.rs Resolved
Comment thread src/storage/src/source/kafka.rs Resolved
Comment thread src/storage/src/source/kafka.rs Resolved
Comment thread src/storage/src/source/kafka.rs Resolved
Comment thread src/storage/src/source/kafka.rs Resolved
Comment thread src/storage/src/source/kafka.rs Resolved
@petrosagg

Copy link
Copy Markdown
Contributor Author

Also, I feel like keeping the OffsetCommitter trait, but its your call!

I fear that this trait will have the same shortcomings as the original data traits in that you can't describe very well your topology. For example if to commit offsets there is some information that needs to be exchanged between the workers then you're hosed so I think it's much easier for each source to handle the stream as it pleases.

I'm not super happy with the offset_commit_loop thingies in this PR but I think they can be written in a better way. I didn't want to make this PR too big for this reason

@guswynn guswynn 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.

I'm not super happy with the offset_commit_loop thingies in this PR but I think they can be written in a better way. I didn't want to make this PR too big for this reason

this seems like a reasonable path forward

@aljoscha aljoscha 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.

This is looking pretty sweet! I had some comments about operator naming and logging, but those should be easy to address.

What's up with the failing nighly, though?

Comment thread src/storage/src/render/mod.rs Resolved
Comment thread src/storage/src/source/kafka.rs Resolved
Comment thread src/storage/src/source/kafka.rs Resolved
Comment thread src/storage/src/source/postgres.rs Resolved
It's a type, so it should be there.

Signed-off-by: Petros Angelatos <[email protected]>
@petrosagg

Copy link
Copy Markdown
Contributor Author

What's up with the failing nighly, though?

I ran the bounded_memory nightly on this PR on the hopes that it would fix the upsert issue. That was before I found the actual bug. In other words, nothing to worry about.

@petrosagg
petrosagg force-pushed the source-connection-render branch 2 times, most recently from ed54848 to 69c4b67 Compare April 2, 2023 17:47
@petrosagg
petrosagg enabled auto-merge April 2, 2023 17:47
@petrosagg
petrosagg disabled auto-merge April 2, 2023 17:52
@petrosagg
petrosagg force-pushed the source-connection-render branch from 69c4b67 to 579c71f Compare April 2, 2023 17:54
@petrosagg
petrosagg enabled auto-merge April 2, 2023 17:55
This commit defines the `SourceRender` trait which supercedes all the
previous ways a source could be defined. Sources are now able to render
arbitrary dataflows, taking advantange of multiple communicating timely
operators when needed.

A lot of the auxiliary types that used to support the old traits have
been removed.

Signed-off-by: Petros Angelatos <[email protected]>
This commit applies a few simplifications in the process of converting
the source to the `SourceRender` trait by being smarter with how
capabilities are managed.

Specifically, the operator does *not* downgrade its capability for every
message. Instead, it exhausts all the available messages from the
partitions which are emitted with the same capability but at different
times (a la DD triplets) and then downgrades the capability of each
partition onces.

This produces a significant performance boost in the feature benchmarks:

```
NAME                      |    THIS     |    OTHER    |  Regression?  | 'THIS' is:
----------------------------------------------------------------------------------------------------
KafkaEnvelopeNoneBytes    |      11.524 |      12.409 |      no       | 7.1 pct   faster
KafkaUpsert               |       3.163 |       5.172 |      no       | 38.8 pct   faster
KafkaUpsertUnique         |       4.436 |       5.180 |      no       | 14.4 pct   faster
```

Signed-off-by: Petros Angelatos <[email protected]>
@petrosagg
petrosagg force-pushed the source-connection-render branch 2 times, most recently from d31c063 to 2f0e05c Compare April 3, 2023 08:43
Instead, log the error to the source status collection and request a
`SuspendAndRestart`.

This commit also introduces a mandatory 30s backoff before a
`SuspendAndResume` takes place, to limit hot retry loops. This comes at
the expense of latency in the case of a transient error; unfortunately
implementing a smarter retry policy (like exponential backoff) is
difficult.

Fix #18491.
@petrosagg
petrosagg force-pushed the source-connection-render branch from 2f0e05c to f171a23 Compare April 3, 2023 10:26
@petrosagg
petrosagg merged commit 762302a into MaterializeInc:main Apr 3, 2023
@petrosagg
petrosagg deleted the source-connection-render branch April 3, 2023 10:51
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.

4 participants