Antonio Silva
05/06/2024, 2:21 PMSTREAM_INITIAL_POSITION to LATEST we're still consuming all the events in the 7 day retention of our Kinesis streams... This means that the STREAM_INITIAL_POSITION config is not being respected when we add a new stream. After some tests this seems to be the case only when restoring from a snapshot.
After some investigation, the culprit seems to be in FlinkKinesisConsumer#run in the code surrounded by if (sequenceNumsToRestore != null) which currently works as follows:
IF there is restore state for ANY shard
IF the current shard has restore state
use offset from restore state
ELSE
start from earliest
ELSE
start from initial position from configs
where we think the correct behaviour would be
IF there is restore state for ANY shard of this particular stream
IF the current shard has restore state
use offset from restore state
ELSE
start from earliest
ELSE
start from initial position from configs
so that when a stream is seen for the firs time, the initial position from the config is used instead of defaulting to earliest.
Would love to discuss this further if needed.
Let me know if there is a better way to formulate this issue and ask for a fix.
Thank you!Hong Teoh
05/06/2024, 2:22 PMHong Teoh
05/06/2024, 2:22 PMAntonio Silva
05/06/2024, 2:35 PMsequenceNumsToRestore. This way we ensure the two state variables are always in sync and we only need one state variable.
The "downside" would be having to iterate over the existing keys to get the stream names, but it looks like the code already iterates over all entries both when restoring from state #initializeState and when storing the state #snapshotState) so I think it would be fine.Antonio Silva
05/06/2024, 2:36 PMHong Teoh
05/06/2024, 2:38 PMAntonio Silva
05/06/2024, 2:38 PMHong Teoh
05/06/2024, 2:38 PMInstead of storing all the configured streams, I think it's safer to use the set of streams present in the existingYep, I've made that suggestion in the JIRA - I've checked we already have sufficient information in. This way we ensure the two state variables are always in sync and we only need one state variable.sequenceNumsToRestore
StreamShardMetadata to figure out what the stream names of previously seen streams are πHong Teoh
05/06/2024, 2:40 PMHong Teoh
05/06/2024, 2:41 PMAntonio Silva
05/06/2024, 2:42 PMAntonio Silva
05/06/2024, 2:42 PMHong Teoh
05/06/2024, 2:43 PMHong Teoh
05/06/2024, 2:46 PMAntonio Silva
05/06/2024, 2:49 PMAntonio Silva
05/06/2024, 2:50 PMHong Teoh
05/06/2024, 3:11 PMNo problem! Do you know usually how long it takes for these issues to be picked up, fixed and released ?Hmm, it's flexible, and we can push a release if we need to. There are some release candidate preparation / voting that needs to be done. Probably O(months)?
Hong Teoh
05/06/2024, 3:12 PMIf it helps, I can fork the repo and get an MR up pretty soon but not sure about how long it takes to run/add tests and the overall review and release process... this would be my first Flink contributionSure thing! I can help with the review if you want. Just let me know
Aleksandr Pilipenko
05/06/2024, 3:21 PMHong Teoh
05/06/2024, 3:22 PMAntonio Silva
05/06/2024, 3:24 PMProbably O(months)?In that case we need some workaround for now - we're leaning towards having an extra property in our app to indicate if it is a new stream being onboarded, then we check if the stream the event is coming from is in the list and in that case ignore all events until a specific timestamp/offset. When we have a working solution I can update this thread or the jira ticket to help others who may face the same issue in the meantime.
I can help with the review if you wantDo I need a Jira account to assign the ticket or I can i leave it as unassigned as long as I reference it in the PR title ?
Hong Teoh
05/06/2024, 3:26 PMHong Teoh
05/06/2024, 3:26 PMAntonio Silva
05/06/2024, 3:27 PMHong Teoh
05/06/2024, 3:28 PMDo I need a Jira account to assign the ticket or I can i leave it as unassigned as long as I reference it in the PR title ?Yeah, you would need to request a ASF Jira account, then I can assign the issue to you, but you should be able to write a PR anyways. Do let me know when you start work on it though, so I can assign the JIRA to prevent duplicate work
Hong Teoh
05/06/2024, 3:28 PMHong Teoh
05/07/2024, 10:36 AMAntonio Silva
05/07/2024, 10:40 AMAntonio Silva
05/07/2024, 10:41 AMHong Teoh
05/07/2024, 10:43 AMwe thought about it but were concerned about the performance hit of having to "merge" the multiple data streams after consumingI think the logic here is that we do a
keyBy / HASH after the source anyways to redistribute the records across multiple downstream subtasks. So single consumer (multiple streams) vs multiple consumers would not have much differenceHong Teoh
05/07/2024, 10:43 AMAntonio Silva
05/07/2024, 10:44 AMI think the logic here is that we do aNot sure where that is being done, we are using an explicit/keyByafter the source anyways to redistribute the records across multiple downstream subtasks.HASH
rebalance to redistribute the records otherwise they were only handled by the consuming subtasksAntonio Silva
05/07/2024, 10:44 AMHong Teoh
05/07/2024, 10:44 AMHong Teoh
05/07/2024, 10:45 AMMaybe its an opt-in feature and we're missing the config?I'm not sure what feature you're talking about!
Antonio Silva
05/07/2024, 10:45 AMI think the logic here is that we do aI thought you meant the flink kinesis connector was already doing this π/keyByafter the source anyways to redistribute the records across multiple downstream subtasksHASH
Antonio Silva
05/07/2024, 10:47 AMHong Teoh
05/07/2024, 10:47 AMAntonio Silva
05/07/2024, 10:48 AMHong Teoh
05/07/2024, 10:49 AMA bug/feature request related to this bug we're tackling is that once that the snapshot is aware of the offset of a stream, there is no way to make it forget it so that we can start from LATEST or go back to EARLIEST (for some specific stream(s) only, if we wanted to do this for all I'm sure we could find a way to rename the task or something that would reset the state)Yes, thats why we are considering deprecating the multi-stream use case. IMO it introduces too much complexity on the source for too little benefit
Hong Teoh
05/07/2024, 10:49 AMI guess if you're deprecating multi stream support the intial position config may already be per stream, so we can probably leverage that or even add a flag to ignore the state for a particular stream.We are doing this as part of migration to the "new" Source V2 API (FLIP-27) - so it would be a hard cut - there will be new configs etc.!
Antonio Silva
05/07/2024, 11:00 AMmain without my changes and I still see a lot of tests fail.
Are the tests also ran in any pipeline when I open the PR, or do I need to ensure they are all passing locally before opening the PR ?Aleksandr Pilipenko
05/07/2024, 11:03 AMAntonio Silva
05/07/2024, 11:04 AMAntonio Silva
05/07/2024, 11:05 AMAleksandr Pilipenko
05/07/2024, 11:11 AMAntonio Silva
05/07/2024, 11:30 AMAntonio Silva
05/07/2024, 11:32 AMHong Teoh
05/07/2024, 11:33 AMHong Teoh
05/07/2024, 11:33 AMAntonio Silva
05/07/2024, 11:34 AMAntonio Silva
05/07/2024, 12:01 PMAntonio Silva
07/08/2024, 10:36 AMAntonio Silva
07/08/2024, 10:36 AMAntonio Silva
07/08/2024, 10:36 AMAntonio Silva
07/08/2024, 10:54 AMantssilva96 so the ticket can be assigned to someone and prevent duplicate work, but I guess I don't have permission to change the assignee.Danny Cranmer
07/08/2024, 12:48 PMAntonio Silva
07/08/2024, 12:50 PMAntonio Silva
07/09/2024, 12:00 PMAntonio Silva
09/04/2024, 1:37 PMAntonio Silva
09/04/2024, 1:37 PMAntonio Silva
11/27/2024, 11:44 AM