nspcc-dev / nspcc-dev/neofs-node
Prefixed keys in session token storage
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 38
- Forks
- 51
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 38
Description
Is your feature request related to a problem? Please describe.
I'm always frustrated when RemoveOldTokens iterates over every key in the sessions bucket and deserializes each token value to check its epoch. This becomes increasingly expensive as the number of stored sessions grows.
Describe the solution you'd like
Store two keys per token in the same bucket using prefixes:
{pref_0}{acc}token data (forGetToken, O(1) lookup){pref_1}{epoch}{acc}empty value (epoch index)
RemoveOldTokens then uses Seek({pref_1}) and iterates only over expired index entries. Both keys are written atomically in one transaction on save. A migration will be needed to rewrite existing entries into the new key format.
Describe alternatives you've considered
Keep the current implementation as-is — simpler, but suboptimal for large numbers of sessions.
Additional context
https://github.com/nspcc-dev/neofs-node/pull/3817#discussion_r2832300875
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing RemoveOldTokens and GetToken in the session token storage implementation, then inspect the sessions bucket transaction used when saving tokens. Done means token data and epoch index entries use the requested prefixes, saving writes both atomically, RemoveOldTokens scans only the epoch index, and existing entries are migrated.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend, distributed-systems
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100