cockroach icon indicating copy to clipboard operation
cockroach copied to clipboard

Support INSERT & UPDATE of implicit regional by row partitioning under READ COMMITTED isolation

Open mw5h opened this issue 1 year ago • 1 comments

Under non-Serializable isolations, we need to lock the keys for unique indexes with implicit partitioning in all partitions to ensure a racing write doesn't insert a conflicting row into a different partition. Since there is no support for predicate locks at the KV layer, we fake it by writing tombstone values to the partitions not being inserted into. This causes a bit of a write explosion, but it will keep conflicting rows from being written.

In this patch, we create the infrastructure for writing these tombstones by modifying the RowHelper to generate a list of keys to lock.

For unique indexes with a single ENUM implicit partition column (e.g. regional by row), write a tombstone to each partition to ensure uniqueness when isolation level is not serializable.

This patch also reverts previous work on the insert fast path to write tombstones because those tombstones are now being written by the row inserter.

mw5h avatar Aug 28 '24 22:08 mw5h

This change is Reviewable

cockroach-teamcity avatar Aug 28 '24 22:08 cockroach-teamcity

@rytaft @mgartner I added a test for implicit partitioning, but not for sharded indexes. It turns out that those already worked, so I just deleted the logic around them in opt_catalog.go.

mw5h avatar Sep 26 '24 19:09 mw5h

Your pull request contains more than 1000 changes. It is strongly encouraged to split big PRs into smaller chunks.

:owl: Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

blathers-crl[bot] avatar Oct 11 '24 22:10 blathers-crl[bot]

RFAL

mw5h avatar Oct 14 '24 18:10 mw5h

bors r+

mw5h avatar Oct 14 '24 20:10 mw5h