Skip to content

[BUG] Tracking table items not cleaned after client disconnect #4143

Description

@JimB123

Describe the bug

TrackingTable in tracking.c is a RAX of key->RAX. The inner RAX is a set of client IDs. When a client is deleted, it isn't removed from this table (intentionally) to avoid an O(N) operation.

The tracking table gets cleaned when the key is modified/deleted.

A problem occurs when clients access a number of keys, and then disconnect. If the keys are rarely modified, the inner RAX grows with invalid clients and is never cleaned up. This can result in unbounded growth on the inner table.

NOTE: The outer table has a maximum size and will discard keys once that size is hit. But there is no limit on the inner table.

ALSO - it appears that there is no defragmentation applied to the TrackingTable. This makes it likely that small buckets 8/16 bytes will be unable to defragment if TrackingTable entries are present.

To reproduce

Create many clients with tracking enabled to connect, read a large set of keys, then disconnect — and those keys are rarely/never modified afterward. This leaves the inner rax entries permanently occupied with dead client IDs.

Expected behavior

  • There should be a limitation on the inner rax size (in aggregate)
  • A mechanism must exist to clean up dead entries (sweeper?)
  • Defragmentation should be applied to the TrackingTable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions