Skip to content

[core] Tolerate retracting an absent secondary index key - #10280

Open
LuciferYang wants to merge 1 commit into
apache:masterfrom
LuciferYang:m/core-100-inmem-retract
Open

LuciferYang wants to merge 1 commit into
apache:masterfrom
LuciferYang:m/core-100-inmem-retract

Conversation

@LuciferYang

Copy link
Copy Markdown
Contributor

Purpose

InMemorySetState.retract did values.get(wrapBytes(serializeKey(key))).remove(...) with no null check, so retracting a key that was never added throws a NullPointerException. This is reachable in a lookup.cache = MEMORY secondary-index lookup join with a filter: SecondaryIndexLookupTable.refreshRow only adds to the index state when the predicate passes (+I / +U) but retracts unconditionally on -D / -U, so a row that was filtered out is never added, and its later retract crashes the lookup refresh. The disk-backed sibling LocalKvSetState.retract already treats an absent key as a no-op, so the same join crashes only in MEMORY cache mode.

This adds the null guard so InMemorySetState.retract no-ops on an absent key, matching the disk-backed contract. The present-key path is unchanged.

This closes #10279.

Tests

  • InMemorySetStateTest#testRetractOnAbsentKeyIsNoOp pins that retracting an absent key is a no-op. Without the fix it throws NullPointerException.

API and Format

No.

Documentation

No.

InMemorySetState.retract dereferenced the per-key set without a null
check, unlike the RocksDB sibling. The lookup refresh path retracts
DELETE and UPDATE_BEFORE rows unconditionally while predicate-filtered
INSERTs never add the secondary key, so a filtered-out row's delete
crashed the lookup operator with an NPE.

Skip the removal when the key is absent.

Assisted-by: GLM-5.3
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.

InMemorySetState.retract NPEs on an absent secondary-index key in MEMORY-cache lookup join

1 participant