Commit 72079c7
committed
GOCBC-1828: Ensure that any initial fatal range scan errors are returned immediately
Motivation
==========
When there is a fatal error from the initial scan create calls, cancelCh is closed, followed by the resultCh once all worker goroutines are stopped. However, when the relevant select statement that waits for either is called, depending on the timing, they can both be closed, in which case one of the two cases is selected at random.
This can result in either getting the error immediately from the Collection.Scan call (which is the intended behaviour), or returning a ScanResult that has its error field populated. So the error will still be returned to the user, but at a different point.
Changes
=======
* Only wait for the resultCh to either be closed or have a value before returning from the Collection.Scan call. When the range scan is canceled, resultCh will also be closed.
* If we do not receive at item from resultCh, then check if we have a fatal error from the range scan and return it. This is equivalent to the original intended behaviour, but ensures that we always return the error immediately when it is present.
Change-Id: Ie713546e73820527fc36679eb702b0233b418707
Reviewed-on: https://review.couchbase.org/c/gocb/+/245725
Tested-by: Build Bot <build@couchbase.com>
Reviewed-by: Charles Dixon <chvckd@gmail.com>1 parent 5badc84 commit 72079c7
1 file changed
Lines changed: 6 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
471 | 471 | | |
472 | 472 | | |
473 | 473 | | |
474 | | - | |
475 | | - | |
476 | | - | |
477 | | - | |
478 | | - | |
479 | | - | |
480 | | - | |
481 | | - | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
482 | 480 | | |
483 | 481 | | |
484 | 482 | | |
| |||
0 commit comments