Skip to content

[DocDB] Tablet splitting: improve middle key selection in case of small key space #27335

@arybochkin

Description

@arybochkin

Jira Link: DB-16844

Description

There's a scenario when a tablet contains the majority of rows with the same key which equals to the lower bound of the tablet. In this case the calculated middle key will match the lower bound and the tablet splitting will fail with error:

I0518 06:15:15.456789 1322400 async_rpc_tasks.cc:1708] Get Tablet Split Key RPC for tablet 0x000037ae6bef8000 -> 7d70d7b738ef46199f5b257c5c7797cc (table demo [id=52293055107d4799a252ef2b1b7a7eee]) (demo [id=52293055107d4799a252ef2b1b7a7eee]) (task=0x000037ae46cec100, state=kRunning): TS 1f05adc2d1dd4cd898a64edd468ddaaa: GetSplitKey (attempt 1) failed for tablet 7d70d7b738ef46199f5b257c5c7797cc with error code TABLET_SPLIT_KEY_RANGE_TOO_SMALL: Illegal state (yb/tablet/tablet.cc:4043): Failed to detect middle key for tablet 7d70d7b738ef46199f5b257c5c7797cc (key_bounds: "472E00" - ""): got "472E00".: TABLET_SPLIT_KEY_RANGE_TOO_SMALL (tablet server error 31)
I0518 06:15:15.45800 1322400 async_rpc_tasks.cc:339] Get Tablet Split Key RPC for tablet 0x000037ae6bef8000 -> 7d70d7b738ef46199f5b257c5c7797cc (table demo [id=52293055107d4799a252ef2b1b7a7eee]) (demo [id=52293055107d4799a252ef2b1b7a7eee]) (task=0x000037ae46cec100, state=kFailed): No reschedule for this task: kFailed

That is an expected failure to prevent creating empty tablets.

However, it is required to improve the logic and return the next key, following the initial key. It will allow to split successfully. This approach should be put under the gflag and is used carefully as it can produce the very uneven split (e.g. 99% of rows in the first tablet and 1% of rows in the second tablet). Also corresponding cli tool should be updated to make split_tablet command force this behaviour.

Issue Type

kind/enhancement

Warning: Please confirm that this issue does not contain any sensitive information

  • I confirm this issue does not contain any sensitive information.

Metadata

Metadata

Assignees

Labels

area/docdbYugabyteDB core featureskind/enhancementThis is an enhancement of an existing featurepriority/highHigh Priority

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions