Skip to content

Conversation

@psrok1
Copy link
Member

@psrok1 psrok1 commented Sep 17, 2025

Karton uses CLIENT NAME to bind Karton service metadata with Redis connection. This information is used for counting active replicas and for removing inactive non-persistent queues.

The problem is that in case of concurrent Redis calls, more than one connection may be used by the client. Initially I thought that this can be fixed by single_connection_client option that sets a lock in connection pool instead of spawning new connections. Unfortunately, asyncio Redis client still keeps two connections opened, making replicas count value completely unreliable.

This PR contains two changes:

  • introduces instance_id in KartonServiceInfo object and generated during KartonBase construction (or in KartonBackend if someone uses it standalone). All connections coming from the same instance of service should have same instance_id
  • instance_id can be passed as an argument to "hello" request in Karton Gateway, along with other KartonServiceInfo information.
  • KartonServiceInfo.karton_version is optional to be able to parse all CLIENT NAME values to KartonServiceInfo, regardless of whether they have extended fields or not.

The replica counting logic should be as follows:

  • KartonServiceInfo.instance_id=<uuid> : objects should be deduplicated by instance_id and each object should be counted as a separate replica of identity
  • KartonServiceInfo.instance_id=None (coming from <6.0.0): each object should be counted as a separate replica of identity

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.

2 participants