Skip to content

[fix] Make clear operations idempotent#126

Merged
0oshowero0 merged 3 commits into
Ascend:mainfrom
0oshowero0:clear
Jun 17, 2026
Merged

[fix] Make clear operations idempotent#126
0oshowero0 merged 3 commits into
Ascend:mainfrom
0oshowero0:clear

Conversation

@0oshowero0

Copy link
Copy Markdown
Collaborator

Background

Previously, the clear operations (kv_clear, (async_)clear_samples, and (async_)clear_partition) were not idempotent: they would raise errors when asked to clear non-existent keys or partitions.

This strict behavior was originally intended to expose potential implementation bugs. As the codebase has matured, we now align these operations with the common idempotent clear semantics, where clearing non-existent data is a no-op and is only logged.

Changes

  1. Controller-level clear_meta / clear_partition / reset_consumption
  • Skip non-existent partitions and global indexes with an info/warning log instead of raising ValueError.
  • In clear_meta, continue processing remaining partitions when one partition does not exist, instead of returning early.
  1. kv_retrieve_meta
  • When create=False, filter out non-existent keys and return a BatchMeta containing only the existing keys, instead of returning an empty BatchMeta.
  • This makes downstream kv_clear naturally idempotent for partial or fully missing keys.
  1. Logging
  • Rephrase clear-related log messages to be grammatically correct and more natural (e.g., "Trying to clear a non-existent partition ... No action taken.").
  1. Tests
  • Add test_controller_clear_meta_idempotent to verify idempotent clear_meta behavior.
  • Add test_controller_kv_retrieve_meta_partial_keys_without_create to verify partial key retrieval.
  • Add test_kv_clear_idempotent in TestKVClearE2E to cover clearing non-existent keys, non-existent partitions, mixed existent/non-existent keys, and repeated clears.

Signed-off-by: 0oshowero0 <o0shower0o@outlook.com>
Signed-off-by: 0oshowero0 <o0shower0o@outlook.com>
Signed-off-by: 0oshowero0 <o0shower0o@outlook.com>
Copilot AI review requested due to automatic review settings June 17, 2026 11:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@ascend-robot

Copy link
Copy Markdown

CLA Signature Pass

0oshowero0, thanks for your pull request. All authors of the commits have signed the CLA. 👍

@0oshowero0 0oshowero0 merged commit 9d99ae5 into Ascend:main Jun 17, 2026
8 checks passed
@0oshowero0 0oshowero0 deleted the clear branch June 17, 2026 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants