Tencent / TBase

TBase is an enterprise-level distributed HTAP database. Through a single database cluster to provide users with highly consistent distributed database services and high-performance data warehouse services, a set of integrated enterprise-level solutions is formed.
Other
1.38k stars 262 forks source link

Regression for `insert .. select..` in 2.3.0 #125

Open yazun opened 2 years ago

yazun commented 2 years ago

We are suffering from regression introduced by https://github.com/Tencent/TBase/commit/df822f2db1693ac030e16aa0473540780ea76991 We have insert ... select ... that used to work before 2.3.0 that does not anymore for no reason really (select is from the replicated table to sharded one

insert into rundataspec (runid, dataSpecId, dataSpecType, sourceIds, status)  select 17 as runId, dataSpecId, 0::smallint dataSpecType, ('{' || leftid || ',' || rightid || '}')::bigint[] sourceIds, 0::smallint status  from catalogdataspec where catalogid = 5007;
ERROR:  shard table could not be inserted from any other tables in different group
Time: 0.566 ms
(cu7user@[local:/tmp/pg_stat_tmp/xztest]:24531) [surveys] >

 \d+ catalogdataspec
                                Table "cu7user.catalogdataspec"
   Column   |   Type   | Collation | Nullable | Default | Storage | Stats target | Description
------------+----------+-----------+----------+---------+---------+--------------+-------------
 catalogid  | smallint |           | not null |         | plain   |              |
 dataspecid | integer  |           | not null |         | plain   |              |
 leftid     | bigint   |           | not null |         | plain   |              |
 rightid    | bigint   |           | not null |         | plain   |              |
Indexes:
    "catalogdataspec_pkey" PRIMARY KEY, btree (catalogid, dataspecid) CLUSTER, tablespace "output_tablespace"
Foreign-key constraints:
    "catalogdataspec_catalog_fkey" FOREIGN KEY (catalogid) REFERENCES catalog(catalogid) ON DELETE CASCADE
Tablespace: "output_tablespace"
Distribute By: REPLICATION
Location Nodes: ALL DATANODES
Options: fillfactor=100
yazun commented 2 years ago

For now we change the line https://github.com/Tencent/TBase/blob/master/src%2Fbackend%2Fparser%2Fanalyze.c#L727 to

(from_rel_loc_info->groupId != target_rel_loc_info->groupId && from_rel_loc_info->locatorType != LOCATOR_TYPE_REPLICATED))
JennyJennyChen commented 2 years ago

Thank you for your feedback, we have assigned relevant personnel (Andre Lin ) to analyze and solve the problem

JennyJennyChen commented 2 years ago

hello, Development engineers have fixed this issue and submitted to:
https://github.com/Tencent/TBase/commit/5efe8f20ecfcf50937ed79610338eb65b5591b51

yazun commented 2 years ago

Appreciated! Thank you.