Add connector SPI for scale writers options#18561
Conversation
core/trino-spi/src/main/java/io/trino/spi/connector/WriterScalingOptions.java
Outdated
Show resolved
Hide resolved
core/trino-spi/src/main/java/io/trino/spi/connector/WriterScalingOptions.java
Outdated
Show resolved
Hide resolved
core/trino-spi/src/main/java/io/trino/spi/connector/WriterScalingOptions.java
Outdated
Show resolved
Hide resolved
7fee7ec to
3b4bbc8
Compare
3b4bbc8 to
85793a9
Compare
85793a9 to
2ac76ee
Compare
There was a problem hiding this comment.
taskScalingMaxWriterCount - is this per task or per table writer node?
There was a problem hiding this comment.
We also have another method getMaxWriterTasks in the SPI which helps to control the maximum number of tasks. How about if we put it in the WriterScalingOptions itself? cc @raunaqmorarka
There was a problem hiding this comment.
I'm not clear on why getMaxWriterTasks was introduced. If it was to limit the maximum amount of write parallelism to an external data source, then the presence of per-task scaling already breaks that.
Per task writer scaling should probably be disabled when getMaxWriterTasks returns something non-empty, as it appears that jdbc connectors call this "write_parallelism".
We should probably deal with that separately to avoid getting blocked on that.
There was a problem hiding this comment.
getMaxWriterTasks was introduced to limit number of writing tasks. From what I know jdbc connectors need that and use that - I know it from talks with different people - I did not confirm that so I am not sure.
It does not interfere with parallelism within task because it limit statically number of tasks.
If getMaxWriterTasks is not empty we could disable "local" scaling or "respect" this limit in local scaling.
@gaurav8297 , is it hard to disable / respect this number?
There was a problem hiding this comment.
then the presence of per-task scaling already breaks that.
Yes, but after this PR we won't have writer scaling enabled for JDBC connectors.
As @radek-starburst mentioned, getMaxWriterTasks is there to limit the number of writing tasks. It doesn't have any control over what happens within a task. If a connector wants to control parallelism with scaling, then they ideally should set the value of both maxWriterTasks and perTaskMaxWriterCount.
Or, maybe instead of having two properties, we can have just one property maxWriters which controls the total number of writers in the cluster. We can look into this in future.
There was a problem hiding this comment.
Also, I think this property works even when you've scaling disabled which is a case where we assign writing tasks to all the available workers.
There was a problem hiding this comment.
I can see that getMaxWriterTasks limits number of writing tasks. The question is what underlying problem were we trying to solve by doing that ? If this was about limiting parallelism, then we need to change getMaxWriterTasks to getMaxWriterParallelism and implementing that should disable within task writer scaling. We can do it as a follow-up since landing this PR will side step the problem for now, but we should fix the API.
There was a problem hiding this comment.
We can do it as a follow-up since landing this PR will side step the problem for now, but we should fix the API.
Yes, we should to it.
|
Can you please move |
raunaqmorarka
left a comment
There was a problem hiding this comment.
lgtm
Needs eyes from other reviewers as well
core/trino-spi/src/main/java/io/trino/spi/connector/WriterScalingOptions.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
I'm not clear on why getMaxWriterTasks was introduced. If it was to limit the maximum amount of write parallelism to an external data source, then the presence of per-task scaling already breaks that.
Per task writer scaling should probably be disabled when getMaxWriterTasks returns something non-empty, as it appears that jdbc connectors call this "write_parallelism".
We should probably deal with that separately to avoid getting blocked on that.
|
the CI seems red |
sopel39
left a comment
There was a problem hiding this comment.
lgtm % comments. I agree with @raunaqmorarka on 2ac76ee#r1287956305
testing/trino-testing/src/main/java/io/trino/testing/TestingConnectorBehavior.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/metadata/MetadataManager.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/sql/planner/LocalExecutionPlanner.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/sql/planner/LocalExecutionPlanner.java
Outdated
Show resolved
Hide resolved
core/trino-spi/src/main/java/io/trino/spi/connector/WriterScalingOptions.java
Outdated
Show resolved
Hide resolved
plugin/trino-hive/src/main/java/io/trino/plugin/hive/HiveMetadata.java
Outdated
Show resolved
Hide resolved
thanks for thumbs up. feel free to link the PR here once it's created. |
6164754 to
32525ce
Compare
32525ce to
95fb70b
Compare
core/trino-main/src/main/java/io/trino/metadata/MetadataManager.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/sql/planner/sanity/ValidateScaledWritersUsage.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
nit: that has quadratic cost (copying lists over and over)
There was a problem hiding this comment.
@gaurav8297 @raunaqmorarka do we want to keep perTaskMaxScaledWriterCount as it seems redundant per previous discussion?
There was a problem hiding this comment.
I think we should keep it for now since it helps to limit parallelism. In future, we can look into combining both maxWriterTasks and this property into a single one.
Using WriterScalingOptions connector can control scaling by providing the following configurations. 1. isWriterTasksScalingEnabled 2. isPerTaskWriterScalingEnabled 3. perTaskMaxScaledWriterCount Additionally, for now scaling is only enabled for hive, iceberg and delta connector.
95fb70b to
fa5eb8e
Compare
|
thx! |
Description
Additional context and related issues
Release notes
( ) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
( ) Release notes are required, with the following suggested text: