-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kvcoord: merge budgets for in-flight writes and lock spans
Before this patch, the txnPipeliner maintained two different memory budgets: 1) kv.transaction.max_intents_bytes - a limit on a txn's lock spans 2) kv.transaction.write_pipelining_max_outstanding_size - a limit on a txn's in-flight writes Besides protecting memory usage, these guys also prevent the commit's Raft command from becoming too big. Having two budgets for very related things is unnecessary. In-flight writes frequently turn into lock spans, and so thinking about how one of the budget feeds into the other is confusing. The exhaustion of the in-flight budget also had a hand in this, by turning in-flight writes into locks immediately. This patch makes write_pipelining_max_outstanding_bytes a no-op. max_intent_bytes takes on also tracking in-flight writes. A request whose async consensus writes would push this budget over the limit is not allowed to perform async-consensus, on the argument that performing sync writes is better because the locks from those writes can be condensed. This patch is also done with an eye towards offering an option to reject transactions that are about to go over budget. Having a single budget to think about makes that conceptually simpler. Release note (general change): The setting `kv.transaction.write_pipelining_max_outstanding_size` becomes a no-op. Its function is folded into the `kv.transaction.max_intents_bytes` setting.
- Loading branch information
1 parent
92d6493
commit 4dc342e
Showing
6 changed files
with
298 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright 2021 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package kvcoord | ||
|
||
import ( | ||
"sort" | ||
|
||
"github.com/cockroachdb/cockroach/pkg/roachpb" | ||
) | ||
|
||
// asSortedSlice returns the set data in sorted order. | ||
// | ||
// Too inefficient for production. | ||
func (s *condensableSpanSet) asSortedSlice() []roachpb.Span { | ||
set := s.asSlice() | ||
cpy := make(roachpb.Spans, len(set)) | ||
copy(cpy, set) | ||
sort.Sort(cpy) | ||
return cpy | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.