4paradigm / 4paradigm/OpenMLDB
create table bug in parallel
- 主要言語
- C++
- スター
- 1.7k
- フォーク
- 331
- 平均マージ
- 12日 12時間
- マージ済み PR(30日)
- 1
説明
## Reproduce steps(demo docker is recommended)
```
./init.sh
openmldb/bin/openmldb --zk_cluster=127.0.0.1:2181 --zk_root_path=/openmldb --role=sql_client --cmd="create database db"
# exec in background, so it can be parallel
openmldb/bin/openmldb --zk_cluster=127.0.0.1:2181 --zk_root_path=/openmldb --role=sql_client --database=db --cmd="create table t1(c1 string, c2 int, c3 bigint, c4 float, c5 double, c6 timestamp, c7 date)" &
openmldb/bin/openmldb --zk_cluster=127.0.0.1:2181 --zk_root_path=/openmldb --role=sql_client --database=db --cmd="create table t1(c1 string, c2 int, c3 bigint, c4 float, c5 double, c6 timestamp, c7 date)" &
```
Here, we'll create two tables with the same name, and nameserver will miss the second table, only cache the first table in `db_table_info_`. (the newer table is not inserted, cuz we use std::map::insert)
But there're two tables, tid is different, you can check it in zookeeper by
```
/work/openmldb/zookeeper/bin/zkCli.sh -server 127.0.0.1:2181
get /openmldb/table/db_table_data/6
get /openmldb/table/db_table_data/7
```
You can check the only table in nameserver by
```
curl http://localhost:7527/NameServer/ShowTable -d'{"db":"db","table":"t1"}' | grep -Eo '"tid":[0-9]*'
```
For example, in my env, it shows `"tid":6`, so table tid 7 is missing.
The problem is that, you can drop table
```
openmldb/bin/openmldb --zk_cluster=127.0.0.1:2181 --zk_root_path=/openmldb --role=sql_client --database=db --cmd="drop table t1"
```
And the table 6 is deleted, you can't find it in nameserver:
```
curl http://localhost:7527/NameServer/ShowTable -d'{"db":"db","table":"t1"}'
{"code":0,"msg":"ok"}
```
But sql client will find the table 7 after refresh the catalog, cuz zookeeper has table 7.
```
openmldb/bin/openmldb --zk_cluster=127.0.0.1:2181 --zk_root_path=/openmldb --role=sql_client --database=db --cmd="show tables"
--------
Tables
--------
t1
--------
1 rows in set
```
Not the same table, but it looks like we can't drop the table.
## How to fix
We can restart the nameserver, it'll recover the missing table.
But we should avoid to create tables with the same name in parallel.
コントリビューションガイド
調査の方向性
The issue involves the nameserver's table cache (`db_table_info_`) using std::map::insert, which fails on concurrent creation. Examine the nameserver code handling table creation and caching, likely in a file like nameserver/table_manager.cc or similar. Reproduce with the provided steps using the demo docker. Check zookeeper paths /openmldb/table/db_table_data/ to see both table entries. The fix must ensure atomicity or conflict detection for parallel CREATE TABLE with the same name.
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- sql
- 領域
- databases, distributed-systems
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 35/100