Skip to content

changefeedccl: allow topic_name parameter for changefeed kafka sinks#62377

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
HonoreDB:specify_topic_name
Mar 23, 2021
Merged

changefeedccl: allow topic_name parameter for changefeed kafka sinks#62377
craig[bot] merged 1 commit intocockroachdb:masterfrom
HonoreDB:specify_topic_name

Conversation

@HonoreDB
Copy link
Copy Markdown
Contributor

Previously, changes for a table went to a Kafka topic
named for that table, with users only able to specify a prefix.
Some users, however, need changes to go to a specific topic,
including sometimes the same one for more than one table,
distinguishing messages using metadata.
This patch allows the ?topic_name=foo parameter to be added
to Kafka sink URIs. This will override the per-table topic
generation, so that changes for every table will all go to
the specified topic. It may be used in conjunction with
topic_prefix, although the distinction is not meaningful.

Release note (enterprise change): Kafka sink URIs now accept
the "topic_name" parameter to override per-table topic names.

Closes #59300
Closes #58302

@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

Copy link
Copy Markdown
Contributor

@miretskiy miretskiy left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @HonoreDB and @stevendanna)


pkg/ccl/changefeedccl/changefeedbase/options.go, line 95 at r1 (raw file):

distinguishing messages using metadata.
This patch allows the ?topic_name=foo parameter to be added
to Kafka sink URIs.

Question:
Is this truly only applicable to kafka?

If so, perhaps parameter should be called kafka_topic_name?

@HonoreDB
Copy link
Copy Markdown
Contributor Author


pkg/ccl/changefeedccl/changefeedbase/options.go, line 95 at r1 (raw file):

Previously, miretskiy (Yevgeniy Miretskiy) wrote…

distinguishing messages using metadata.
This patch allows the ?topic_name=foo parameter to be added
to Kafka sink URIs.

Question:
Is this truly only applicable to kafka?

If so, perhaps parameter should be called kafka_topic_name?

It is currently only applicable to Kafka, as is topic_prefix which is a name we're stuck with. It does seem like it could potentially generalize to other sinks? Not sure.

Copy link
Copy Markdown
Contributor

@miretskiy miretskiy left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 4 files at r1.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @miretskiy and @stevendanna)

@miretskiy miretskiy self-requested a review March 22, 2021 21:36
Copy link
Copy Markdown
Collaborator

@stevendanna stevendanna left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @HonoreDB and @miretskiy)


pkg/ccl/changefeedccl/sink.go, line 370 at r1 (raw file):

	topics := make(map[descpb.ID]string)
	useSingleName := false
	if useSingleName = (name != ""); useSingleName {

[nit] Since useSingleName is used outside this if, might it be more clear to initialize it as:

useSingleName := (name != "")

at 369?

Copy link
Copy Markdown
Collaborator

@stevendanna stevendanna left a comment

Choose a reason for hiding this comment

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

:lgtm: Meant to hit "approve" the first time as my only comment is a nit. This looks good and I think opens up more straightforward usage for many users.

Reviewed 4 of 4 files at r1.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @HonoreDB and @miretskiy)

Previously, changes for a table went to a Kafka topic
named for that table, with users only able to specify a prefix.
Some users, however, need changes to go to a specific topic,
including sometimes the same one for more than one table,
distinguishing messages using metadata.
This patch allows the `?topic_name=foo` parameter to be added
to Kafka sink URIs. This will override the per-table topic
generation, so that changes for every table will all go to
the specified topic. It may be used in conjunction with
topic_prefix, although the distinction is not meaningful.

Release note (enterprise change): Kafka sink URIs now accept
the "topic_name" parameter to override per-table topic names.
@HonoreDB HonoreDB force-pushed the specify_topic_name branch from e640e79 to 296223c Compare March 23, 2021 14:28
@HonoreDB
Copy link
Copy Markdown
Contributor Author


pkg/ccl/changefeedccl/sink.go, line 370 at r1 (raw file):

Previously, stevendanna (Steven Danna) wrote…

[nit] Since useSingleName is used outside this if, might it be more clear to initialize it as:

useSingleName := (name != "")

at 369?

Yup, my way made no sense. Fixed.

Copy link
Copy Markdown
Contributor Author

@HonoreDB HonoreDB left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @miretskiy and @stevendanna)


pkg/ccl/changefeedccl/sink.go, line 370 at r1 (raw file):

Previously, HonoreDB (Aaron Zinger) wrote…

Yup, my way made no sense. Fixed.

Done.

@HonoreDB
Copy link
Copy Markdown
Contributor Author

bors r=[stevendanna, miretskiy]

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Mar 23, 2021

Build failed (retrying...):

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Mar 23, 2021

Build failed (retrying...):

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Mar 23, 2021

Build succeeded:

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.

cdc: pass an (arbitrary) kafka topic name in the destination path string Allow multiple changefeed jobs to emit to the same topic

4 participants