greptimedb icon indicating copy to clipboard operation
greptimedb copied to clipboard

Use UUID as table id instead of `u32`

Open v0y4g3r opened this issue 2 years ago • 0 comments

Background

Currently TableId is an alias of u32, and forms the most significant 32 bits of region id. But generating monotonously increasing table id requires extra API for metasrv.

Proposal

Change table id from u32 to UUID (which is infact a u128 generated in some specific rule), to avoid stateful API from metasrv.

API change

Region id (an alias for u64) is generated from table id and region number, and should be changed from u64 to [u8; 20](16 bytes for table id and 32 bytes for region number).

https://github.com/GreptimeTeam/greptimedb/blob/999cd310c099926ecbcb0137939ef53e66e64dc7/src/table/src/metadata.rs#L11

This will also affect region name. https://github.com/GreptimeTeam/greptimedb/blob/999cd310c099926ecbcb0137939ef53e66e64dc7/src/table-engine/src/engine.rs#L38-L40

CatalogManager::next_table_id should return an UUID instead of u32. https://github.com/GreptimeTeam/greptimedb/blob/8269c0adff145f589dd4d28d4670a52b79cc1242/src/catalog/src/lib.rs#L73

Also, in distributed mode, table id should generate in frontend, and passed to datanodes through CreateExpr: https://github.com/GreptimeTeam/greptimedb/blob/cc0c883ee24ff3f4a6110b278ed7b3bdef3d0ac7/src/api/greptime/v1/admin.proto#L32-L42

v0y4g3r avatar Nov 07 '22 07:11 v0y4g3r