Repository navigation
fix(datastore): make push() fail loudly and stop mutating shared query - #11
Open
adamsrnmsu wants to merge 1 commit into
Open
adamsrnmsu wants to merge 1 commit into
adamsrnmsu wants to merge 1 commit into
Conversation
push() deleted existing documents by query and then ignored the False returned by bulk_push_docs, so a failed push silently lost the deleted data. The grouped path also appended to and popped from one shared query["bool"]["must"] list inside a loop. Fix: build a fresh query per group, and raise RuntimeError when bulk_push_docs returns False. The only caller (push_results_to_es) already catches and logs exceptions, so it now reports the failure instead of "results pushed". True atomicity (push, then delete only older docs) is not possible with the current client API: documents have no ids to exclude, so a delete >= min timestamp after the push would remove the new documents too. Failure is made loud instead. Verified: - tests/test_datastore_push.py: 5 pass; on the old code the grouped independent-query and failed-push tests fail. - Full suite failures match the base (Elasticsearch-only + macOS path). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
datastore/query_api.pypush()deletes the existing documents by query and then bulk-pushes the new ones. It ignored theFalsethatbulk_push_docsreturns on a failed document, so a failed push silently lost the data it had just deleted. The grouped path also appended to and popped from one sharedquery["bool"]["must"]list inside its loop.Fix: a fresh query per group, and
RuntimeErrorwhenbulk_push_docsreturnsFalse. The only caller,push_results_to_es, already catches and logs exceptions, so a failure is now logged as an error instead of "results pushed".True atomicity (push first, then delete only the older documents) is not possible with the current client API: the documents have no ids to exclude, so deleting at or after the minimum timestamp after the push would delete the new documents too. This PR makes the failure loud instead.
Related Issues/PRs
add_must_sub_queryin the same file (a different function); ci(release): adopt releasaurus with CalVer and the phenix-apps contribution workflow #3 fixes a typo in the same file. Small textual rebase at most.Type of Change
fix)feat)docs)refactor)chore)Checklist
Testing
tests/test_datastore_push.py(5 tests): ungrouped delete-then-push order, grouped pushes use independent queries, no delete whenoverwrite_oldisFalse, a failed push raises, input documents unchanged. On the old code the grouped and failed-push tests fail.mainand no new ones (Elasticsearch-server tests, plus the macOS-onlytest_build_paths_uses_var_lib_for_manifest_state).Additional Notes
With grouping, a failure part-way through the per-group deletes still leaves the earlier groups deleted; this PR only makes the push failure visible.
🤖 Generated with Claude Code