Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
76761: kvstreamer: improve behavior when responses vary in size r=yuzefovich a=yuzefovich **kvstreamer: create Results for empty Get responses** We recently merged a change to skip Get responses that came back empty (because there is no corresponding key found) in the `Streamer` which cleaned up some code. However, for the upcoming work on the `InOrder` mode the `Streamer` needs to know about such responses. We could introduce a separate tracking mechanism for empty Get responses and continue not emitting them, but that seems like unnecessary complication to the code, so this commit, instead, restores the creation of Results for empty Get responses. Additionally it fixes a nit in the test where we hard-code the table ID (table IDs recently have changed a bit). Release note: None **colfetcher: fix memory limiting in the ColIndexJoin** `ColIndexJoin` operator carefully measures the footprint of the input rows that it uses to generate spans to lookup. It wants to find the largest number of rows that have the total footprint not exceeding the target size (4MiB or a quarter of `workmem`, whichever is smaller), but always it includes at least one row into the "input batch". Previously, it incorrectly could include an extra row when the limit is reached because we incorrectly determined whether any rows are already included into the input batch (essentially we always thought "no"). This commit fixes this problem. Release note: None **kvstreamer: fix a couple of bugs** This commit fixes a rare concurrency bug where the newly enqueued requests could be incorrectly sliced off. This could occur because it is possible for a request to be issued asynchronously, responded to, returned to the client before the deferred function in `issueRequestsForAsyncProcessing` is executed. For the time being the fix is to just append the newly-enqueued requests to the old ones, but the follow-up work on the `InOrder` mode will clean this up properly. Additionally, this commit fixes another deadlock that could occur whenever the last request in flight returns without creating any results and the worker coordinator is waiting for more budget at the same time. Previously, it was possible for the signal on the condition variable to be missed by the worker coordinator, so it could wait forever. There are no explicit regression tests for these bugs because they are exercised by the improved testing in the following commit. Release note: None **kvstreamer: improve behavior when responses vary in size** This commit improves the behavior of the `Streamer` when the responses vary in size significantly. Previously, we could get into a situation when the `Streamer` issues many requests that come back with empty responses because `TargetBytes` limit is too small. This can be the case when some small responses come back first making our estimate for the average response size to be too small, and we later would use that estimate to set the `TargetBytes` limit on the new requests. If those new requests have large responses, we would keep getting empty responses until a request becomes the "head-of-the-line" (we could issue hundreds of such requests that would receive empty response). This behavior is now fixed by utilizing `ResumeNextBytes` hint from the KV layer about the size of the next KV pair. The KV layer on a best-effort basis provides this hint whenever it cannot fulfill the request fully. If a particular request keeps getting an empty response, we ensure that it is always issued with a larger `TargetBytes` limit every time. This commit additionally adds some `Printf` statements hidden behind a constant `debug=false` flag. I want to keep this in code for the time being since it's been very helpful during the debugging. Since it's a compile time constant set to `false`, it should have no performance impact. In order to verify that the `Streamer` does, in fact, make a reasonable number of KV requests, an existing test has been refactored and extended. In particular, it now looks at the trace of the query and counts how make async requests are issued by the `Streamer`. Release note: None Co-authored-by: Yahor Yuzefovich <yahor@cockroachlabs.com>
- Loading branch information