GreptimeTeam / greptimedb

An open-source, cloud-native, unified time series database for metrics, logs and events with SQL/PromQL supported. Available on GreptimeCloud.
https://greptime.com/
Apache License 2.0
4.23k stars 303 forks source link

Discuss: Behavior of preserved table id (0~1023) and system tables #1782

Open waynexia opened 1 year ago

waynexia commented 1 year ago

What type of enhancement is this?

Refactor, Tech debt reduction

What does the enhancement do?

The first 1024 numbers are preserved for special system table (defined in the constant MAX_SYS_TABLE_ID). In practice those ID are allocated statically (in code) to system tables. E.g., 0 for SystemCatalog table and 1 for ScriptsTable.

One key difference between those 1024 special IDs and other normal table IDs is, those 1024 IDs will be duplicated cross different catalogs. Since we put table ID in the data path, it's not allowed to have the same table ID for different table otherwise their data will be mixed up. Except they don't have persisted state.

Luckily, this constrain holds for most system table, like information_schema.tables, information_schema.metrics, public.numbers etc. But other tables like scripts should not have a static ID because they have to write data.

Based on this, my perspectives to preserved table IDs are:

Implementation challenges

No response

tisonkun commented 6 months ago

@waynexia it seems that:

/// system_catalog table id
pub const SYSTEM_CATALOG_TABLE_ID: u32 = 0;
/// scripts table id
pub const SCRIPTS_TABLE_ID: u32 = 1;

these two consts are no longer used. What's the status of this issue now?