Hi everyone! I am using Flink 1.20 on Python and T...
# pyflink
а
Hi everyone! I am using Flink 1.20 on Python and Table API & SQL. The data source is a Kafka topic, which contains info about user's login and logout, and I need to make the correct sequence login -> logout -> login, but sometimes the topic can receive several duplicate login/logout entries in a row with a small time difference. To get rid of duplicates, I used the Lag function for the login/logout field and an event time watermark for order. Example of query:
Copy code
...
FROM (
      SELECT *,
            LAG(event_type, 1, 'first_row') OVER (PARTITION BY user_id ORDER BY create_ts_ltz) AS prev_event
        FROM user_auth
     )
WHERE prev_event <> event_type
Sometimes there is a problem that the sequence is broken in the sink topic, because Lag (Flink?) skips some event from the source topic, although it is there (especially the first entries). When I try to read the time interval where the data was lost using batch mode with the same SQL query that works in streaming mode, then all data is returned correctly, so I have no idea why the loss is happening. (I also noticed that if you run a query with Lag function on a topic, specifying the
scan.startup.mode = earliest-offset
, then out of 10000 entries of the source topic, only 4000 may reach the sink topic, although in reality there are no such duplicates) Has anyone faced with similar behavior? Thanks in advance!
v
can you please share the data samples? I'll try to replicate this
а
hi, thanks! here is the data sample
v
Sure, ill check this