cockroach icon indicating copy to clipboard operation
cockroach copied to clipboard

pq: update-setting: split failed while applying backpressure: could not find valid split key

Open hongbin0908 opened this issue 7 years ago • 12 comments

Describe the problem

where I change setting or change schema, it report:

/defaultdb> SET CLUSTER SETTING kv.range.backpressure_range_size_multiplier=0;
pq: update-setting: split failed while applying backpressure: could not find valid split key

Environment:

  • CockroachDB version [2.1.6]
  • Server OS: [Linux/Distrib]
  • Client app [cockroach sql`]

hongbin0908 avatar Mar 18 '19 05:03 hongbin0908

Hey @hongbin0908 ,

This error split failed while applying backpressure: could not find valid split key usually happens when a single range has so many MVCC versions that it takes up more than 128 MB (twice the max range size of 64 MB).

I would suggest lowing the gc.ttlseconds to something lower, by default it is 90000s.

You can change it using the command ALTER RANGE default CONFIGURE ZONE USING gc.ttlseconds = <seconds>

Thanks!

roncrdb avatar Apr 02 '19 18:04 roncrdb

#30956

roncrdb avatar Apr 02 '19 19:04 roncrdb

It turns out to be surprisingly easy to trigger this error: inserting 8193 16KB values is sufficient. See https://github.com/cockroachdb/cockroach/issues/35699#issuecomment-479551312 and use https://gist.github.com/twpayne/7da8892eed03d948464671a51949e7e9 to reproduce.

twpayne avatar Apr 03 '19 19:04 twpayne

@nvanbenschoten is this the issue where you've somehow concluded that range 6 is the one that can't be split? If so, I think I've remembered the cause that I had found before where looking at something similar: a long-running schema change was updating the respective table descriptor every few minutes to write a new "schema change lease". But that appears unlikely to be the cause here, since @twpayne's script has no schema changes.

andreimatei avatar May 16 '19 21:05 andreimatei

I took a look at @twpayne's script (thanks for that!). It turns out that in the configuration referenced here, it's actually triggering the expected case for write backpressure. When batchSize := 1, numBatches := 10000, and valueSize := 16 * 1024, it ends up repeatedly updating the same 16KB row 10,000 times. We were seeing that write backpressure kicks in on the 8183rd pair, which lines up:

16KB * 8182 = 134,053,888 bytes < 2*64MB
16KB * 8183 = 134,070,272 bytes > 2*64MB

In that case, the backpressure is protecting the single row from causing a range to exceed twice the max range size. Any larger than this and the range could start to become a risk for instability. So, unfortunately, that won't help us track down this issue.

What we see here is that a schema change is somehow causing range 6 (grouped in with the cluster settings table) to grow to a point where it's hitting this same backpressure mechanism. This is bad, especially because it's really difficult to get around. We should split the cluster settings from other ranges to prevent issues like this from ever materializing.

I'd also like to explore this "long-running schema change was updating the respective table descriptor every few minutes to write a new schema change lease" theory. @andreimatei do you have any links to this?

nvb avatar May 20 '19 17:05 nvb

@nvanbenschoten I know there's been ongoing work on this, but if you're not the right owner let me know.

tim-o avatar Jun 05 '19 10:06 tim-o

Zendesk ticket #3392 has been linked to this issue.

tim-o avatar Jun 05 '19 14:06 tim-o

Hey @hongbin0908 ,

This error split failed while applying backpressure: could not find valid split key usually happens when a single range has so many MVCC versions that it takes up more than 128 MB (twice the max range size of 64 MB).

I would suggest lowing the gc.ttlseconds to something lower, by default it is 90000s.

You can change it using the command ALTER RANGE default CONFIGURE ZONE USING gc.ttlseconds = <seconds>

Thanks!

Hi @roncrdb ,

I keep getting the same error(split failed) even whenever I try to make some change on the tables or applying any changes on the settings.

root@crdb:26257/defaultdb> ALTER RANGE default CONFIGURE ZONE USING gc.ttlseconds =900; pq: update-zone: split failed while applying backpressure: could not find valid split key

I've also tried to change the setting through the below commands, yet it throws out the same error - set cluster setting kv.range_split.by_load_enabled = false; pq: update-setting: split failed while applying backpressure: could not find valid split key

Do you have any idea what's happening in here? or any way to troubleshoot this issue?

anoasis avatar Jul 05 '19 20:07 anoasis

Hey @hongbin0908 , This error split failed while applying backpressure: could not find valid split key usually happens when a single range has so many MVCC versions that it takes up more than 128 MB (twice the max range size of 64 MB). I would suggest lowing the gc.ttlseconds to something lower, by default it is 90000s. You can change it using the command ALTER RANGE default CONFIGURE ZONE USING gc.ttlseconds = <seconds> Thanks!

Hi @roncrdb ,

I keep getting the same error(split failed) even whenever I try to make some change on the tables or applying any changes on the settings.

root@crdb:26257/defaultdb> ALTER RANGE default CONFIGURE ZONE USING gc.ttlseconds =900; pq: update-zone: split failed while applying backpressure: could not find valid split key

I've also tried to change the setting through the below commands, yet it throws out the same error - set cluster setting kv.range_split.by_load_enabled = false; pq: update-setting: split failed while applying backpressure: could not find valid split key

Do you have any idea what's happening in here? or any way to troubleshoot this issue?

Here is my session logs - https://gist.github.com/anoasis/21413fe785410ee417baea2b5b32494e

anoasis avatar Jul 05 '19 20:07 anoasis

@nvanbenschoten was testing YCSB a bit more. an extremely corner case with a single key update. this condition gets triggered as below with CRDB 19.2.1

cockroach workload init ycsb --insert-start 0 --insert-count 1 --families=False
cockroach workload run ycsb --insert-start 0 --insert-count 1 --concurrency 1 --duration 120s --workload a
cockroach workload run ycsb --insert-start 0 --insert-count 1 --concurrency 1 --duration 60s --workload a

Error: pq: split failed while applying backpressure to [txn: b732085f], Put [/Table/67/1/"user12161962213042174405"/0,/Min), EndTransaction(commit:true) [/Table/67/1/"user12161962213042174405"/0] on range r44:/{Table/67-Max} [(n1,s1):1, next=2, gen=15]: could not find valid split key

changing the gc.ttlsecond does provide the relief.

root@:26257/ycsb> show ranges from table usertable;
  start_key | end_key | range_id | range_size_mb | lease_holder | lease_holder_locality | replicas | replica_localities
+-----------+---------+----------+---------------+--------------+-----------------------+----------+--------------------+
  NULL      | NULL    |       46 |    134.217904 |            1 |                       | {1}      | {""}
(1 row)

ALTER RANGE default CONFIGURE ZONE USING gc.ttlseconds = 1;

root@:26257/ycsb> show ranges from table usertable;
  start_key | end_key | range_id | range_size_mb | lease_holder | lease_holder_locality | replicas | replica_localities
+-----------+---------+----------+---------------+--------------+-----------------------+----------+--------------------+
  NULL      | NULL    |       46 |      1.603233 |            1 |                       | {1}      | {""}
(1 row)

robert-s-lee avatar Dec 18 '19 00:12 robert-s-lee

We have marked this issue as stale because it has been inactive for 18 months. If this issue is still relevant, removing the stale label or adding a comment will keep it active. Otherwise, we'll close it in 10 days to keep the issue queue tidy. Thank you for your contribution to CockroachDB!

github-actions[bot] avatar Sep 22 '21 11:09 github-actions[bot]

I try to evaluate recent version of cockroach DB performance using its embedded YCSB workload. Each node running workload uses concurrency 512 and local HAProxy. When I have up to 4 nodes everything is OK, when I run load on 5 or mode nodes then I get this error: Error: pq: split failed while applying backpressure to Put [/Table/106/1/"user12161962213042174405"/10/1,/Min), EndTxn(parallel commit) [/Table/106/1/"user12161962213042174405"/10/1], [txn: 5db7c8f2] on range r1358:/Table/106/1/"user121619622{13042174405"-45824696597"} [(n4,s14):4, (n2,s5):2, (n1,s3):3, next=5, gen=54, sticky=1669995204.433364679,3]: could not find valid split key

I will try to decrease TTL for MVCC

eivanov89 avatar Dec 06 '22 14:12 eivanov89