Skip to content

NO_TOKEN creates zombie entries in _reader map before validity check #84

Description

@bigsamich

Description

In RedisAdapter.cpp:274-280, add_reader_helper inserts into _reader[token] before checking if token == NO_TOKEN:

uint32_t token = reader_token(key);
reader_info& info = _reader[token];      // creates _reader[NO_TOKEN] entry
info.subs[key].push_back(func);
info.keyids[key] = "$";
if (token == NO_TOKEN) return false;     // too late — entry already created

While the reconnect logic (line 426) does handle NO_TOKEN entries, this ordering is fragile and creates map entries that may never be cleaned up if reconnect doesn't fire.

Severity

High

Suggested Fix

Either check token == NO_TOKEN before accessing the map, or add a comment documenting this as intentional behavior for the reconnect path.

Activity

  1. bigsamich commented on Sep 30, 2026

    @bigsamich
    ContributorAuthor

    Resolved by #108. All three removal paths (removeGenericReader, remove_registration, remove_reader_helper) now scan every bucket, including NO_TOKEN, and erase buckets that become empty.

    On main the failure is sharper than described here. A reader removed while disconnected stays in the NO_TOKEN bucket, reconnect() moves it into a live bucket, and the removed callback keeps receiving data. Verified: 1 entry reached the removed callback on main, and 0 on #108, #109 and #111.

    The NO_TOKEN bucket itself is intentional: it is the pending queue that reconnect() drains. Readers registered while disconnected still start after reconnect on every tree.

    I've suggested adding Fixes #84 to #108, which targets main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions