Skip to content

Commit f7b60e4

Browse files
craig[bot]Abhinav1299stevendanna
committed
148795: kvserver: Remove SnapshotReservationTimeoutError r=Abhinav1299 a=Abhinav1299 SnapshotReservationTimeoutError is a part of the gRPC response error that was getting overly redacted. The overall gRPC response should be handled to fix the over redaction instead just the error part. This patch reverts the #147395. Epic: CRDB-37533 Part of: CRDB-44885 Release note: None 148868: concurrency: disallow lock flushing in production builds r=tbg a=stevendanna This is an undocumented setting that is still under development. While it is undocumented, this additional check will avoid any accidental use. Epic: none Release note: None Co-authored-by: Abhinav1299 <[email protected]> Co-authored-by: Steven Danna <[email protected]>
3 parents ce35c63 + d263ef2 + f29b2f9 commit f7b60e4

File tree

4 files changed

+19
-38
lines changed

4 files changed

+19
-38
lines changed

pkg/kv/kvpb/errors.go

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1828,34 +1828,6 @@ func NewKeyCollisionError(key roachpb.Key, value []byte) error {
18281828
return ret
18291829
}
18301830

1831-
// snapshotReservationTimeoutError represents an error that occurs when
1832-
// giving up during snapshot reservation due to cluster setting timeout.
1833-
type SnapshotReservationTimeoutError struct {
1834-
cause error
1835-
settingName string
1836-
}
1837-
1838-
// Error implements the error interface.
1839-
func (e *SnapshotReservationTimeoutError) Error() string {
1840-
return redact.Sprint(e).StripMarkers()
1841-
}
1842-
1843-
// SafeFormatError implements errors.SafeFormatter.
1844-
func (e *SnapshotReservationTimeoutError) SafeFormatError(p errors.Printer) (next error) {
1845-
p.Printf("giving up during snapshot reservation due to cluster setting %q: %v", redact.SafeString(e.settingName), redact.SafeString(e.cause.Error()))
1846-
return nil
1847-
}
1848-
1849-
// NewSnapshotReservationTimeoutError creates a new SnapshotReservationTimeoutError.
1850-
func NewSnapshotReservationTimeoutError(
1851-
cause error, settingName string,
1852-
) *SnapshotReservationTimeoutError {
1853-
return &SnapshotReservationTimeoutError{
1854-
cause: cause,
1855-
settingName: settingName,
1856-
}
1857-
}
1858-
18591831
// NewExclusionViolationError creates a new ExclusionViolationError. This error
18601832
// is returned by requests that encounter an existing value written at a
18611833
// timestamp at which they expected to have an exclusive lock on the key. This
@@ -1960,5 +1932,4 @@ var _ errors.SafeFormatter = &UnhandledRetryableError{}
19601932
var _ errors.SafeFormatter = &ReplicaUnavailableError{}
19611933
var _ errors.SafeFormatter = &ProxyFailedError{}
19621934
var _ errors.SafeFormatter = &KeyCollisionError{}
1963-
var _ errors.SafeFormatter = &SnapshotReservationTimeoutError{}
19641935
var _ errors.SafeFormatter = &ExclusionViolationError{}

pkg/kv/kvserver/concurrency/concurrency_manager.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"github.com/cockroachdb/cockroach/pkg/settings/cluster"
2525
"github.com/cockroachdb/cockroach/pkg/storage"
2626
"github.com/cockroachdb/cockroach/pkg/storage/enginepb"
27+
"github.com/cockroachdb/cockroach/pkg/util/buildutil"
2728
"github.com/cockroachdb/cockroach/pkg/util/debugutil"
2829
"github.com/cockroachdb/cockroach/pkg/util/hlc"
2930
"github.com/cockroachdb/cockroach/pkg/util/log"
@@ -132,15 +133,27 @@ var UnreplicatedLockReliabilityLeaseTransfer = settings.RegisterBoolSetting(
132133
"kv.lock_table.unreplicated_lock_reliability.lease_transfer.enabled",
133134
"whether the replica should attempt to keep unreplicated locks during lease transfers",
134135
metamorphic.ConstantWithTestBool("kv.lock_table.unreplicated_lock_reliability.lease_transfer.enabled", false),
136+
settings.WithValidateBool(func(_ *settings.Values, enabled bool) error {
137+
if enabled && !buildutil.CrdbTestBuild {
138+
return errors.Newf("kv.lock_table.unreplicated_lock_reliability.lease_transfer.enabled is not supported in production builds")
139+
}
140+
return nil
141+
}),
135142
)
136143

137-
// UnreplicatedLockReliabilityMerge controls whether the replica will
138-
// attempt to keep unreplicated locks during range merge operations.
144+
// UnreplicatedLockReliabilityMerge controls whether the replica will attempt to
145+
// keep unreplicated locks during range merge operations.
139146
var UnreplicatedLockReliabilityMerge = settings.RegisterBoolSetting(
140147
settings.SystemOnly,
141148
"kv.lock_table.unreplicated_lock_reliability.merge.enabled",
142149
"whether the replica should attempt to keep unreplicated locks during range merges",
143150
metamorphic.ConstantWithTestBool("kv.lock_table.unreplicated_lock_reliability.merge.enabled", false),
151+
settings.WithValidateBool(func(_ *settings.Values, enabled bool) error {
152+
if enabled && !buildutil.CrdbTestBuild {
153+
return errors.Newf("kv.lock_table.unreplicated_lock_reliability.merge.enabled is not supported in production builds")
154+
}
155+
return nil
156+
}),
144157
)
145158

146159
var MaxLockFlushSize = settings.RegisterByteSizeSetting(

pkg/kv/kvserver/store_snapshot.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,10 @@ func (s *Store) throttleSnapshot(
273273
if err := ctx.Err(); err != nil {
274274
return nil, errors.Wrap(err, "acquiring snapshot reservation")
275275
}
276-
return nil, kvpb.NewSnapshotReservationTimeoutError(
277-
queueCtx.Err(), string(snapshotReservationQueueTimeoutFraction.Name()),
276+
return nil, errors.Wrapf(
277+
queueCtx.Err(),
278+
"giving up during snapshot reservation due to cluster setting %q",
279+
snapshotReservationQueueTimeoutFraction.Name(),
278280
)
279281
case <-s.stopper.ShouldQuiesce():
280282
return nil, errors.Errorf("stopped")

pkg/kv/kvserver/store_test.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3471,11 +3471,6 @@ func TestReserveSnapshotQueueTimeoutAvoidsStarvation(t *testing.T) {
34713471
if errors.Is(err, context.DeadlineExceeded) {
34723472
return nil
34733473
}
3474-
// Also handle the new SnapshotReservationTimeoutError as a timeout condition
3475-
var snapshotTimeoutErr *kvpb.SnapshotReservationTimeoutError
3476-
if errors.As(err, &snapshotTimeoutErr) {
3477-
return nil
3478-
}
34793474
return err
34803475
}
34813476
defer cleanup()

0 commit comments

Comments
 (0)