Hải Nguyễn
01/25/2024, 4:15 AM()
WITH (
'connector' = 'kafka',
'topic' = 'ODS_STMT_ENTRY_FLINK',
'properties.bootstrap.servers' = 'dc1-dev-kkbro01.seauat.com.vn:9092',
'properties.group.id' = 'ACCT',
'scan.startup.mode' = 'latest-offset',
...
);
My topic ODS_STMT_ENTRY_FLINK has 3 partitions.
Then run the two `select * from `ODS_STMT_ENTRY`` jobs in parallel. As a result, both read all received messages without division. I use flink 1.8, can anyone tell me how to handle it?Woohyuck Choi
01/25/2024, 5:14 AMHải Nguyễn
01/25/2024, 5:46 AMWoohyuck Choi
01/25/2024, 6:02 AMWoohyuck Choi
01/25/2024, 6:51 AMHải Nguyễn
01/25/2024, 7:03 AMWoohyuck Choi
01/25/2024, 7:20 AMCREATE TABLE `ODS_STMT_ENTRY`
(
...
`partition` BIGINT METADATA VIRTUAL,
...
)
WITH (
'connector' = 'kafka',
'topic' = 'ODS_STMT_ENTRY_FLINK',
'properties.bootstrap.servers' = 'dc1-dev-kkbro01.seauat.com.vn:9092',
'properties.group.id' = 'ACCT',
'scan.startup.mode' = 'latest-offset',
...
);
-- job 1 reads from even partitions
INSERT INTO some_sinks AS
SELECT
*
FROM
`ODS_STMT_ENTRY`
WHERE
`partition` % 2 = 0
;
-- job 2 reads from odd partitions
INSERT INTO some_sinks AS
SELECT
*
FROM
`ODS_STMT_ENTRY`
WHERE
`partition` % 2 = 1
;
• per other columns
• randomly (not quite useful), etc
According to the docs and Stackoverflow, Flink commits offsets at checkpoint. (Flink doesn't use the good old subscribe API, but the assign API) Therefore what you tried first (having multiple consumers with the same group id) will not work as expected.
Hope it helps.Hải Nguyễn
01/25/2024, 7:56 AMMartijn Visser
01/25/2024, 9:03 AMI want to use group.id to increase the system's fault tolerance, not to read messages by partitionsFlink relies on its checkpoint/savepoint mechanism for fault tolerance, you can't use Kafka's group.id system for this
Hải Nguyễn
01/25/2024, 9:12 AMMartijn Visser
01/25/2024, 9:13 AMHải Nguyễn
01/26/2024, 2:45 AMMartijn Visser
01/26/2024, 8:37 AMmohan tummala
02/21/2024, 6:58 PM