Report per-record errors in batch_operate instead of aborting the batch#19
Open
zuchmanski wants to merge 1 commit into
Open
Report per-record errors in batch_operate instead of aborting the batch#19zuchmanski wants to merge 1 commit into
zuchmanski wants to merge 1 commit into
Conversation
MultiCommand#parse_group raised Exceptions::Aerospike on any per-record result code other than OK/KEY_NOT_FOUND_ERROR/FILTERED_OUT, before parse_row could record the code. For batch_operate this meant a single bad record (e.g. RECORD_TOO_BIG, BIN_TYPE_ERROR) aborted the entire batch: successful writes were lost and no per-record context reached the caller. Extract the raise decision into an overridable handle_result_code and override it as a no-op in BatchOperateCommand, so non-OK codes fall through to parse_row and are captured on each BatchRecord#result_code. The call now returns normally and the caller inspects status per record, matching respond_all_keys semantics in the Java/C/Go clients. Scan/query (StreamCommand) and legacy batch_get (BatchIndexCommand) keep the existing raising behavior. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
zuchmanski
force-pushed
the
fix/batch-operate-per-record-result-code
branch
from
July 3, 2026 12:31
bc82c94 to
a2fbf02
Compare
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.
Problem
Client#batch_operate(withBatchWrite/BatchUDF/BatchDelete/BatchReadrecords) raisedAerospike::Exceptions::Aerospikeand abandoned the entire batch as soon as one record came back with a non-OK result code (e.g.RECORD_TOO_BIG,PARAMETER_ERROR,BIN_TYPE_ERROR).As a result:
BatchRecord#result_codewas never populated for the failing (or any subsequent) record.Per-record failures should be reported on each
BatchRecord#result_code, leaving successful records applied/returned and the call succeeding — the point of a batch, and how the Java/C/Go clients behave (respond_all_keys).Root cause
MultiCommand#parse_groupraised on any per-record code that wasn't OK /KEY_NOT_FOUND_ERROR/FILTERED_OUT, beforeparse_rowrecorded the code.BatchOperateCommand#parse_rowalready stores the per-record code, but never ran on the failing record becauseparse_groupraised first; the exception then propagated out viathreads.each(&:join)inexecute_batch_operate_commands.Fix
MultiCommand#parse_groupinto an overridablehandle_result_code(result_code). Base behavior is unchanged (raises on unexpected codes).handle_result_codeas a no-op inBatchOperateCommand, so non-OK codes fall through toparse_rowand are captured on eachBatchRecord#result_code. The call returns normally and the caller inspects status per record.Scan/query (
StreamCommand, which has its ownparse_group) and legacybatch_get(BatchIndexCommand) keep the existing raising behavior.Testing
Added a spec that mixes a healthy
BatchWritewith one that deterministically fails (Operation.addon a pre-existing string bin →BIN_TYPE_ERROR), asserting the call doesn't raise, the good record isOKwith its record set, the bad record carriesBIN_TYPE_ERROR, and the good write is durably readable.Verified against a live Aerospike 7.1 server:
batch_operate) and passes with it.batch_operate_spec.rb+batch_spec.rb: 33 examples, 0 failures (legacybatch_getraising path intact).🤖 Generated with Claude Code