Skip to content

Commit 2972f13

Browse files
craig[bot]zachlitenvb
committed
107457: ui: increase hot ranges page timeout r=zachlite a=zachlite This commit increases the hot ranges request timeout to 30 minutes for both the initial fetch and the refresh. Informs #cockroachdb#104269 Epic: none Release note (bug fix): The timeout duration when loading the Hot Ranges page has been increased to 30 minutes. 107468: kv: implement errors.Wrapper on sendError, deflake test r=knz a=nvanbenschoten Fixes cockroachdb#107353. This commit makes `sendError` implement the `errors.Wrapper` interface. This deflakes `TestDefaultConnectionDisruptionDoesNotInterfereWithSystemTraffic`, which was expecting a call to `require.ErrorIs` to find a `context.DeadlineExceeded` in an error chain that included a `sendError`. Release note: None Co-authored-by: zachlite <[email protected]> Co-authored-by: Nathan VanBenschoten <[email protected]>
3 parents 65f591b + f5817b3 + 64cfbb2 commit 2972f13

File tree

6 files changed

+30
-23
lines changed

6 files changed

+30
-23
lines changed

pkg/kv/kvclient/kvcoord/dist_sender.go

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1826,7 +1826,7 @@ func (ds *DistSender) sendPartialBatch(
18261826
// deduceRetryEarlyExitError() call below the loop is inhibited.
18271827
pErr = kvpb.NewError(err)
18281828
switch {
1829-
case errors.HasType(err, sendError{}):
1829+
case IsSendError(err):
18301830
// We've tried all the replicas without success. Either they're all
18311831
// down, or we're using an out-of-date range descriptor. Evict from the
18321832
// cache and try again with an updated descriptor. Re-sending the
@@ -2080,7 +2080,7 @@ func noMoreReplicasErr(ambiguousErr, lastAttemptErr error) error {
20802080
// one to return; we may want to remember the "best" error we've seen (for
20812081
// example, a NotLeaseHolderError conveys more information than a
20822082
// RangeNotFound).
2083-
return newSendError(fmt.Sprintf("sending to all replicas failed; last error: %s", lastAttemptErr))
2083+
return newSendError(errors.Wrap(lastAttemptErr, "sending to all replicas failed; last error"))
20842084
}
20852085

20862086
// defaultSendClosedTimestampPolicy is used when the closed timestamp policy
@@ -2463,7 +2463,7 @@ func (ds *DistSender) sendToReplicas(
24632463
log.VEventf(
24642464
ctx, 2, "transport incompatible with updated routing; bailing early",
24652465
)
2466-
return nil, newSendError(fmt.Sprintf("leaseholder not found in transport; last error: %s", tErr.Error()))
2466+
return nil, newSendError(errors.Wrap(tErr, "leaseholder not found in transport; last error"))
24672467
}
24682468
}
24692469
}
@@ -2705,28 +2705,32 @@ func skipStaleReplicas(
27052705
// TODO(andrei): clean up this stuff and tighten the meaning of the different
27062706
// errors.
27072707
type sendError struct {
2708-
message string
2708+
cause error
27092709
}
27102710

2711-
// newSendError creates a sendError.
2712-
func newSendError(msg string) error {
2713-
return sendError{message: msg}
2711+
// newSendError creates a sendError that wraps the given error.
2712+
func newSendError(err error) error {
2713+
return &sendError{cause: err}
27142714
}
27152715

27162716
// TestNewSendError creates a new sendError for the purpose of unit tests
27172717
func TestNewSendError(msg string) error {
2718-
return newSendError(msg)
2718+
return newSendError(errors.NewWithDepthf(1, "%s", msg))
27192719
}
27202720

2721-
// SendErrorString is the prefix for all sendErrors, exported in order to
2722-
// perform cross-node error-checks.
2723-
const SendErrorString = "failed to send RPC"
2724-
2725-
func (s sendError) Error() string {
2726-
return SendErrorString + ": " + s.message
2721+
// Error implements error.
2722+
func (s *sendError) Error() string {
2723+
return fmt.Sprintf("failed to send RPC: %s", s.cause)
27272724
}
27282725

2726+
// Cause implements errors.Causer.
2727+
// NB: this is an obsolete method, use Unwrap() instead.
2728+
func (s *sendError) Cause() error { return s.cause }
2729+
2730+
// Unwrap implements errors.Wrapper.
2731+
func (s *sendError) Unwrap() error { return s.cause }
2732+
27292733
// IsSendError returns true if err is a sendError.
27302734
func IsSendError(err error) bool {
2731-
return errors.HasType(err, sendError{})
2735+
return errors.HasType(err, &sendError{})
27322736
}

pkg/kv/kvclient/kvcoord/dist_sender_rangefeed.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ func (ds *DistSender) singleRangeFeed(
736736
for {
737737
stuckWatcher.stop() // if timer is running from previous iteration, stop it now
738738
if transport.IsExhausted() {
739-
return args.Timestamp, newSendError("sending to all replicas failed")
739+
return args.Timestamp, newSendError(errors.New("sending to all replicas failed"))
740740
}
741741
maybeCleanupStream()
742742

pkg/kv/kvclient/kvcoord/dist_sender_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3662,7 +3662,7 @@ func TestMultipleErrorsMerged(t *testing.T) {
36623662
abortErr := kvpb.NewTransactionAbortedError(kvpb.ABORT_REASON_ABORTED_RECORD_FOUND)
36633663
conditionFailedErr := &kvpb.ConditionFailedError{}
36643664
writeIntentErr := &kvpb.WriteIntentError{}
3665-
sendErr := sendError{}
3665+
sendErr := &sendError{}
36663666
ambiguousErr := &kvpb.AmbiguousResultError{}
36673667
randomErr := &kvpb.IntegerOverflowError{}
36683668

@@ -4439,7 +4439,7 @@ func TestEvictionTokenCoalesce(t *testing.T) {
44394439
// Return a sendError so DistSender retries the first range lookup in the
44404440
// user key-space for both batches.
44414441
if previouslyWaited := waitForInitialPuts(); !previouslyWaited {
4442-
return nil, newSendError("boom")
4442+
return nil, TestNewSendError("boom")
44434443
}
44444444
return br, nil
44454445
}
@@ -4744,7 +4744,7 @@ func TestRequestSubdivisionAfterDescriptorChangeWithUnavailableReplicasTerminate
47444744
transportFn := func(_ context.Context, ba *kvpb.BatchRequest) (*kvpb.BatchResponse, error) {
47454745
atomic.AddInt32(&numAttempts, 1)
47464746
require.Equal(t, 1, len(ba.Requests))
4747-
return nil, newSendError("boom")
4747+
return nil, TestNewSendError("boom")
47484748
}
47494749
rpcRetryOptions := &retry.Options{
47504750
MaxRetries: 5, // maxAttempts = 6
@@ -5169,7 +5169,7 @@ func TestSendToReplicasSkipsStaleReplicas(t *testing.T) {
51695169
get.Key = roachpb.Key("a")
51705170
ba.Add(get)
51715171
_, err = ds.sendToReplicas(ctx, ba, tok, false /* withCommit */)
5172-
require.IsType(t, sendError{}, err)
5172+
require.IsType(t, &sendError{}, err)
51735173
require.Regexp(t, "NotLeaseHolderError", err)
51745174
cached := rc.GetCached(ctx, tc.initialDesc.StartKey, false /* inverted */)
51755175
require.NotNil(t, cached)

pkg/kv/kvclient/kvcoord/replica_slice.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ package kvcoord
1212

1313
import (
1414
"context"
15-
"fmt"
1615
"sort"
1716
"time"
1817

1918
"github.com/cockroachdb/cockroach/pkg/roachpb"
2019
"github.com/cockroachdb/cockroach/pkg/util/log"
2120
"github.com/cockroachdb/cockroach/pkg/util/shuffle"
21+
"github.com/cockroachdb/errors"
2222
)
2323

2424
// ReplicaInfo extends the Replica structure with the associated node
@@ -134,7 +134,7 @@ func NewReplicaSlice(
134134
}
135135
if len(rs) == 0 {
136136
return nil, newSendError(
137-
fmt.Sprintf("no replica node information available via gossip for r%d", desc.RangeID))
137+
errors.Errorf("no replica node information available via gossip for r%d", desc.RangeID))
138138
}
139139
return rs, nil
140140
}

pkg/ui/workspaces/db-console/src/redux/apiReducers.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ export const hotRangesReducerObj = new PaginatedCachedDataReducer(
126126
api.getHotRanges,
127127
"hotRanges",
128128
hotRangesRequestToID,
129+
1000 /* page limit */,
130+
null /* invalidation period */,
131+
moment.duration(30, "minutes"),
129132
);
130133

131134
export const refreshDatabaseDetails = databaseDetailsReducerObj.refresh;

pkg/ui/workspaces/db-console/src/views/reports/containers/hotranges/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const HotRanges = (props: HotRangesProps) => {
3838
page_size: pageSize,
3939
page_token: pageToken,
4040
});
41-
getHotRanges(request).then(response => {
41+
getHotRanges(request, moment.duration(30, "minutes")).then(response => {
4242
if (response.ranges.length == 0) {
4343
return;
4444
}

0 commit comments

Comments
 (0)