Fix: Disable partial retries + correct RpcContext handling to resolve inconsistent reads when using statement.getMoreResults() (#29451) #29455
+95
−102
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.
Jira Issue: DB-19247
Issue Type: Bug
Area: YSQL
🧩 Issue Summary (from #29451)
This PR fixes inconsistent reads caused when using the JDBC
getMoreResults()API in YSQL workloads. The issue resulted in missing or duplicated row results during multi-resultset queries inside the consistency validation workload.The same workload passes in PostgreSQL but fails in YugabyteDB with off-by-one mismatches such as:
This happens because:
RpcContextwas passed incorrectly by value, causing dropped results during multi-result RPC execution.🔧 Root Cause
getMoreResults()expects all resultsets to remain intact.PgClientServiceImpl::Perform()incorrectly passedRpcContextby value, causing the context to go out of scope while async work was still using it.✅ Fix Summary
This PR contains two critical fixes:
1. Disable Partial-Restart Retries for Multi-Result or Read Batches
Added logic in
PgSession::Perform():disable_retries_on_restarts = true.This prevents tserver from replaying only a subset of the statements, ensuring all resultsets remain consistent across retries.
2. Correct
RpcContextPassing inPgClientServiceImpl::Perform()Updated function signature to pass
rpc::RpcContext*instead of a temporary stack value.This ensures the RPC context remains valid for the duration of async execution.
📝 Files Changed
src/yb/yql/pggate/pg_session.cc— Added detection logic + new Perform option flag.src/yb/yql/pggate/pg_client_service.cc— ChangedPerform()to correctly passRpcContext.🧪 Testing
getMoreResults().