Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Database options do not take effect #4914

Closed
v0y4g3r opened this issue Oct 31, 2024 · 0 comments · Fixed by #4926
Closed

Database options do not take effect #4914

v0y4g3r opened this issue Oct 31, 2024 · 0 comments · Fixed by #4926
Labels
C-bug Category Bugs

Comments

@v0y4g3r
Copy link
Contributor

v0y4g3r commented Oct 31, 2024

What type of bug is this?

Incorrect result

What subsystems are affected?

Other

Minimal reproduce step

  1. Create a database with ttl
mysql -h 127.0.0.1 -P 4002 -e "create database benchmark with (ttl='1d');"
  1. Create a table in that database
mysql -h 127.0.0.1 -P 4002 benchmark -e "CREATE TABLE IF NOT EXISTS cpu ( hostname STRING NULL, region STRING NULL, datacenter STRING NULL, rack STRING NULL, os STRING NULL, arch STRING NULL, team STRING NULL, service STRING NULL, service_version STRING NULL, service_environment STRING NULL, usage_user BIGINT NULL, usage_system BIGINT NULL, usage_idle BIGINT NULL, usage_nice BIGINT NULL, usage_iowait BIGINT NULL, usage_irq BIGINT NULL, usage_softirq BIGINT NULL, usage_steal BIGINT NULL, usage_guest BIGINT NULL, usage_guest_nice BIGINT NULL, ts TIMESTAMP(9) NOT NULL, TIME INDEX (ts), PRIMARY KEY (hostname, region, datacenter, rack, os, arch, team, service, service_version, service_environment));"

What did you expect to see?

The table (and regions in that table) created should inherit the database ttl option

What did you see instead?

The ttl option does not take effect in region level.

What operating system did you use?

NA

What version of GreptimeDB did you use?

0.9.5

Relevant log output and stack trace

In #2341 we introduced procedure framework for fault-tolerant DDL tasks like creating tables. create table procedure are split into several steps, namely creating table metadata and invoking datanodes to create regions.

At the first step, table metadata inherits the database level options. However, the merge result is not reflected in CreateTableExpr itself. So at the second step, which is invoking datanodes to create regions, the CreateTableExpr does not carry any database-level options:

pub fn new_region_request_builder(

So the created regions do not contain schema-level options.

This bug is elusive in that you cannot find that schema options is not applied to regions since all table metadata are correct, so SHOW CREATE TABLE statement can give the correct result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category Bugs
Projects
None yet
1 participant