Skip to content

Fix key deserialization propagation in windows #848

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

gwaramadze
Copy link
Contributor

@gwaramadze gwaramadze commented Apr 18, 2025

Despite key_deserializer being set to json, after windowing, the deserialization is gone, and the key is served back as bytes. Affected windows:

  • sliding
  • tumbling and hopping in closing strategy "partition" mode

Tumbling and hopping windows with the closing strategy "key" are unaffected.

  • The fix for the sliding window was rather trivial. All we need is to use the deserialized key coming directly from process_window instead of the serialized one coming from the store.
    • As a side effect, turns out nothing is utilizing the key from state.expire_windows, so it doesn't need to return it.
  • The fix for the "partition" expiration mode is less elegant; refer to the docstring of _deserialize_prefix for a detailed explanation.

@gwaramadze gwaramadze force-pushed the fix/deserialization-propagation branch from dd3bf22 to 62d6b4e Compare April 18, 2025 12:49
@gwaramadze gwaramadze marked this pull request as ready for review April 21, 2025 08:35
@gwaramadze gwaramadze added the bug Something isn't working label Apr 21, 2025
Comment on lines +413 to +416
When retrieving a prefix during partition-level windows expiration, we
don't know its original type due to this conditional serialization.
Therefore, we must first *try* to deserialize it using the configured
`loads` function.
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we store an indicator about the prefix type, if it's a byte or something else ?

For migration, existing windows missing that information can try to deserialize

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, but it's considerably more code, not sure if it's worth it.

Let's see what @daniil-quix thinks. But even if we decide to do this, it may be done as a separate optimisation; in the meantime, this will fix the bug.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm mostly worried about the performance hit of trying to deserialise every keys

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants