Skip to content

arenaskl: cached Inserter can admit a duplicate successor key #27691

Description

@XuPeng-SH

Problem

A reused arenaskl Inserter can miss equality when the requested key is exactly the cached base-level splice successor. The cached-splice fast path starts the remaining descent below level 0, so that successor is not compared again and a duplicate node can be published.

Reproduction

  1. Insert the even keys with the normal skiplist API.
  2. Reuse one Inserter while adding all keys in sorted order.
  3. Existing even keys should return ErrRecordExists, but without an explicit cached-successor equality check duplicate nodes can be admitted.

Impact

The bug violates the skiplist unique-key contract for callers that reuse Inserter across sorted, overlapping input. It also prevents safely using the splice cache to speed up exact COUNT(DISTINCT) state merges.

Expected fix

Check equality with the cached successor before leaving the cached base-level splice path, and add a regression that verifies both duplicate rejection and final cardinality.

Discovered while optimizing #27672.

Metadata

Metadata

Assignees

Labels

kind/bugSomething isn't workingseverity/s0Active / top priority for current sprint. Owner has committed to working on it now.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions