Summary:
The bug was introduced by the fix for #27695 (D44893), where we may set request bounds based on scan conditions.
We set bounds at request initialization time, and if the new bounds reduce scan range to empty, we set end_of_data_ flag, assuming the scan won't be executed.
However, there was a code path where we created and sent requests regardless of the flag. Because of the end_of_data_ flag, the response was never read, but the query returned an error because of an active operation, es described in #28462.
Since #22826 (D43357), where we changed the way how we fetch responses, the error manifestation had changes. Instead of erroring out, we continued fetch attempts, so the scan was stuck forever, as described in #28476.
In this diff we fix the root cause and don't create requests in the end_of_data_ state. Also we add a number of assertions to catch invalid state more easily.
Jira: DB-18141, DB-18163
Test Plan: ./yb_build.sh release --java-test 'org.yb.pgsql.TestPgRegressParallel#testPgRegressBigParallel'
Reviewers: aagrawal, jason
Reviewed By: jason
Subscribers: yql
Tags: #jenkins-ready
Differential Revision: https://phorge.dev.yugabyte.com/D46459