Skip to content

kv: intent resolution for high priority pushes should not wait for batching #50390

@kocoten1992

Description

@kocoten1992

Describe the problem

When select for update a row, other query running into it will significantly increase cost, example below:

To Reproduce

  1. start fresh ./cockroach start-single-node --insecure
CREATE TABLE test_table (
  id uuid NOT NULL,
  PRIMARY KEY (id)
);

INSERT INTO test_table (id) values ('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa');
INSERT INTO test_table (id) values ('bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb');
  1. open two cockroach shells:
# shell 1
begin;
root@:26257/test_database  OPEN> select * from test_table where id = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' for update;
                   id
----------------------------------------
  aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa
(1 row)

Time: 766.309µs
# shell 2
begin priority high;
root@:26257/default  OPEN> select * from test_table where id = 'bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb' for update;
                   id
----------------------------------------
  bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb
(1 row)

Time: 1.265911ms

root@:26257/default  OPEN> select * from test_table where id = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' for update;
                   id
----------------------------------------
  aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa
(1 row)

Time: 14.729765ms

Notice that, the select time are significantly higher.

I don't know how to get around this ? Maybe we could have a select priority read and skip all of the checking

Because this make our select for update kinda work - but does not truly.

Environment:

  • CockroachDB version: v20.1.1

P/s: another example

# shell 1
begin priority low;
root@:26257/default  OPEN> select * from test_table where id = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' for update;
                   id
----------------------------------------
  aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa
(1 row)

Time: 1.081118ms
# shell 2
# no need transaction here
root@:26257/default> select * from test_table where id = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa';           
                   id
----------------------------------------
  aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa
(1 row)

Time: 19.77373ms

Jira issue: CRDB-4129

Epic CRDB-25218

Metadata

Metadata

Assignees

Labels

A-kv-transactionsRelating to MVCC and the transactional model.A-read-committedRelated to the introduction of Read CommittedC-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.O-communityOriginated from the communityT-kvKV Team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions