Skip to content

fix: _set_keyspace_for_all_pools passes only the last pool's errors to callback#915

Open
mykaul wants to merge 1 commit into
masterfrom
fix/set-keyspace-error-accumulation
Open

fix: _set_keyspace_for_all_pools passes only the last pool's errors to callback#915
mykaul wants to merge 1 commit into
masterfrom
fix/set-keyspace-error-accumulation

Conversation

@mykaul

@mykaul mykaul commented Jun 27, 2026

Copy link
Copy Markdown

Fixes #914

pool_finished_setting_keyspace was calling callback(host_errors) (the last pool to finish) instead of callback(errors) (all accumulated errors).

This caused keyspace changes to silently report success when the last pool finished without errors, even if other pools had failures.

Introduced in d281b50c9 (2013-10-11).

@mykaul mykaul added the bug Something isn't working label Jun 27, 2026
@coderabbitai

coderabbitai Bot commented Jun 27, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 63a95286-ad5a-4cbc-a1a8-5e01fa548649

📥 Commits

Reviewing files that changed from the base of the PR and between 8990563 and 93ca9e5.

📒 Files selected for processing (1)
  • cassandra/cluster.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • cassandra/cluster.py

📝 Walkthrough

Walkthrough

In cassandra/cluster.py, the completion logic of Session._set_keyspace_for_all_pools is corrected so that when the last pool finishes, the callback is invoked with the accumulated errors map instead of the per-pool host_errors variable. Additionally, InvalidRequest is removed from the top-level cassandra import and Tablets is removed from the cassandra.tablets import.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The import cleanup removing InvalidRequest and Tablets is unrelated to the callback bug fix. Remove the unrelated import-surface cleanup or explain it as a necessary part of the bug fix.
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the callback error fix in _set_keyspace_for_all_pools.
Description check ✅ Passed The description summarizes the bug, its impact, and the linked fix issue sufficiently well.
Linked Issues check ✅ Passed The change matches #914 by passing the accumulated errors map to the completion callback.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comment thread cassandra/connection.py Fixed
Comment thread cassandra/protocol.py Fixed
Comment thread cassandra/cqlengine/query.py
Comment thread cassandra/cluster.py
Comment on lines 3438 to 3444
errors[pool.host] = host_errors

if not remaining_callbacks:
callback(host_errors)
callback(errors)

for pool in tuple(self._pools.values()):
pool._set_keyspace_for_all_conns(keyspace, pool_finished_setting_keyspace)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Can you add a regression test for that?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Isn't test_set_keyspace_for_all_pools_reports_all_errors the test for it?

…o callback

The pool_finished_setting_keyspace closure was calling callback(host_errors)
instead of callback(errors), so when the last pool to finish had no errors,
the callback received an empty list instead of the accumulated error dict
from all pools.

This caused _set_keyspace_completed to report success (not [] is True)
even when other pools had failures — keyspace changes silently succeeded
with partial failures dropped.

Introduced in d281b50 (2013-10-11).

Fixes #914
@mykaul mykaul force-pushed the fix/set-keyspace-error-accumulation branch from 8990563 to 93ca9e5 Compare June 30, 2026 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

_set_keyspace_for_all_pools callback receives only the last pool's errors instead of all accumulated errors

2 participants