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

case3 :alter schema with index #2671

Closed
whitewum opened this issue Mar 22, 2021 · 6 comments
Closed

case3 :alter schema with index #2671

whitewum opened this issue Mar 22, 2021 · 6 comments
Assignees
Labels
type/bug Type: something is unexpected wontfix Solution: this will not be worked on recently

Comments

@whitewum
Copy link
Contributor

whitewum commented Mar 22, 2021

These are migration from internal jira reports.

case 1: the same property name, drop it , then re-create it.

image

case2: alter schema change property to a different type (string->int)


create tag test(col1 string , col2 string);

insert vertex test(col1,col2) values "11":("aa","bb");

alter tag test change (col2 int)

(root@nebula) [test2]> fetch prop on test "11"
+----------+-----------+-----------+
| VertexID | test.col1 | test.col2 |
+----------+-----------+-----------+
| "11" | "aa" | {color:#de350b}"bb"{color} |
+----------+-----------+-----------+

 

insert vertex test(col1,col2) values "22":("aa",99)
create tag index test_index on test(col2);

rebuild tag index test_index
+------------+
| New Job Id |
+------------+
| 49 |
+------------+
 show jobs;
+--------+---------------------+------------+------------+------------+
| Job Id | Command | Status | Start Time | Stop Time |
+--------+---------------------+------------+------------+------------+
| 49 | "REBUILD_TAG_INDEX" | "FINISHED" | 1607570799 | 1607570799 |

 

(root@nebula) [test2]> lookup on test where test.col2 < 99 yield test.col2;
+------+----------------------+
| _vid | col2 |
+------+----------------------+
| "11" | {color:#de350b}-2134143272594898944{color} |
+------+----------------------+
Got 1 rows (time spent 1957/3046 us)

case 3: alter schema with index

create tag test4(col1 int,col2 int);

insert vertex test4(col1,col2) values "a":(1,2)

insert vertex test4(col1,col2) values "b":(2,3)

alter tag test4 add (col3 int)

create tag index test4_index on test4(col1,col2,col3);

rebuild tag index test4_index

(root@nebula) [test3]> lookup on test4 where test4.col1 == 2;
Empty set (time spent 2026/2789 us)

case4:default value

# v2.0
(root@nebula) [test1]> create tag tag1(col1 timestamp default 0)
 Execution succeeded (time spent 18185/18647 us)
Tue, 26 Jan 2021 10:35:13 CST
(root@nebula) [test1]> insert vertex tag1() values "1":()
 Execution succeeded (time spent 2850/3427 us)
Tue, 26 Jan 2021 10:35:30 CST
(root@nebula) [test1]> insert vertex tag1() values "2":(111)
 [ERROR (-12)]: SemanticError: Column count doesn't match value count.

v1.0

(root@nebula) [test1]> create tag tag1(col1 timestamp default 0)
Execution succeeded (Time spent: 1.495/2.28 ms)Tue Jan 26 
Tue Jan 26 10:41:22 2021(root@nebula) [test1]> insert vertex tag1() values 1:()
Execution succeeded (Time spent: 1.487/2.372 ms)Tue Jan 26 10:41:32 2021(root@nebula) [test1]> insert vertex tag1() values 2:(10)
Execution succeeded (Time spent: 1.415/2.195 ms)Tue Jan 26 
Tue Jan 26 10:41:45 2021(root@nebula) [test1]> fetch prop on tag1 1
==================================
| VertexID | tag1.col1           |
==================================
| 1        | 1970-01-01 08:00:00 |
----------------------------------
Got 1 rows (Time spent: 1.511/2.596 ms)Tue Jan 26 10:41:49 2021(root@nebula) [test1]> fetch prop on tag1 2
==================================
| VertexID | tag1.col1           |
==================================
| 2        | 1970-01-01 08:00:00 |
----------------------------------
Got 1 rows (Time spent: 1.012/1.632 ms)Tue Jan 26 10:41:51 2021
@CPWstatic CPWstatic transferred this issue from vesoft-inc/nebula-graph Aug 28, 2021
@CPWstatic CPWstatic added the type/bug Type: something is unexpected label Aug 28, 2021
@CPWstatic CPWstatic added this to the v2.6.0 milestone Aug 30, 2021
@CPWstatic
Copy link
Contributor

CPWstatic commented Sep 14, 2021

Prepare the space

(root@nebula) [(none)]> create space test1(vid_type=fixed_string(30))
Execution succeeded (time spent 39512/41812 us)

Tue, 14 Sep 2021 10:27:53 CST

(root@nebula) [(none)]> use test1
[ERROR (-1005)]: SpaceNotFound:

Tue, 14 Sep 2021 10:27:56 CST

(root@nebula) [(none)]> use test1
Execution succeeded (time spent 48813/51626 us)

Tue, 14 Sep 2021 10:27:58 CST

Case 1 : the same property name, drop it , then re-create it.

(root@nebula) [test1]> create tag test3(col1 string, col2 string);
Execution succeeded (time spent 46958/49297 us)

Tue, 14 Sep 2021 10:28:24 CST

(root@nebula) [test1]> insert vertex test3(col1, col2) value "11":("col1", "col2");
Execution succeeded (time spent 8589/11521 us)

Tue, 14 Sep 2021 10:29:04 CST

(root@nebula) [test1]> alter tag test3 drop (col2);
Execution succeeded (time spent 31366/36053 us)

Tue, 14 Sep 2021 10:29:53 CST

(root@nebula) [test1]> fetch prop on test3 "11";
+-----------------------------+
| vertices_                   |
+-----------------------------+
| ("11" :test3{col1: "col1"}) |
+-----------------------------+
Got 1 rows (time spent 6965/10054 us)

Tue, 14 Sep 2021 10:30:08 CST

(root@nebula) [test1]> alter tag test3 add (col2 string default "xxxx");
Execution succeeded (time spent 25945/28989 us)

Tue, 14 Sep 2021 10:30:52 CST

(root@nebula) [test1]> fetch prop on test3 "11";
+-----------------------------+
| vertices_                   |
+-----------------------------+
| ("11" :test3{col1: "col1"}) |
+-----------------------------+
Got 1 rows (time spent 5199/7972 us)

Tue, 14 Sep 2021 10:30:57 CST

(root@nebula) [test1]> fetch prop on test3 "11";
+-------------------------------------------+
| vertices_                                 |
+-------------------------------------------+
| ("11" :test3{col1: "col1", col2: "col2"}) |
+-------------------------------------------+
Got 1 rows (time spent 6125/9092 us)

Tue, 14 Sep 2021 10:31:00 CST

This problem is due to that the columns have no version, so if the column is deleted first and then added back to the tags/edges, we can still read the value after all. This is a known issue, we could add it to v3.0 roadmap. @Sophie-Xie

Case 2: alter schema change property to a different type (string->int)

(root@nebula) [test1]> create tag test(col1 string , col2 string);
Execution succeeded (time spent 83144/85189 us)

Tue, 14 Sep 2021 10:38:20 CST

(root@nebula) [test1]> insert vertex test(col1,col2) values "11":("aa","bb");
Execution succeeded (time spent 6843/9300 us)

Tue, 14 Sep 2021 10:38:42 CST

(root@nebula) [test1]> fetch prop on test "11"
+--------------------------------------+
| vertices_                            |
+--------------------------------------+
| ("11" :test{col1: "aa", col2: "bb"}) |
+--------------------------------------+
Got 1 rows (time spent 11830/14468 us)

Tue, 14 Sep 2021 10:38:58 CST

(root@nebula) [test1]> alter tag test change (col2 int)
Execution succeeded (time spent 40178/44064 us)

Tue, 14 Sep 2021 10:41:12 CST

(root@nebula) [test1]> fetch prop on test "11"
+--------------------------------------+
| vertices_                            |
+--------------------------------------+
| ("11" :test{col1: "aa", col2: "bb"}) |
+--------------------------------------+
Got 1 rows (time spent 9940/13559 us)

Tue, 14 Sep 2021 10:41:18 CST

(root@nebula) [test1]> insert vertex test(col1,col2) values "22":("aa",99)
Execution succeeded (time spent 15569/18790 us)

Tue, 14 Sep 2021 10:42:04 CST

(root@nebula) [test1]> create tag index test_index on test(col2);
Execution succeeded (time spent 68325/71791 us)

Tue, 14 Sep 2021 10:42:08 CST

(root@nebula) [test1]> rebuild tag index test_index
+------------+
| New Job Id |
+------------+
| 30         |
+------------+
Got 1 rows (time spent 61606/66416 us)

Tue, 14 Sep 2021 10:42:13 CST

(root@nebula) [test1]> show jobs
+--------+---------------------+------------+-------------------------+-------------------------+
| Job Id | Command             | Status     | Start Time              | Stop Time               |
+--------+---------------------+------------+-------------------------+-------------------------+
| 30     | "REBUILD_TAG_INDEX" | "FINISHED" | 2021-09-14T02:42:13.000 | 2021-09-14T02:42:13.000 |
+--------+---------------------+------------+-------------------------+-------------------------+
Got 1 rows (time spent 17940/20785 us)

Tue, 14 Sep 2021 10:42:17 CST

(root@nebula) [test1]> lookup on test where test.col2 < 99 yield test.col2;
+----------+----------------------+
| VertexID | test.col2            |
+----------+----------------------+
| "11"     | -2134143272594898944 |
+----------+----------------------+
Got 1 rows (time spent 13113/16100 us)

Tue, 14 Sep 2021 10:42:34 CST

The problem is that the tag/edge have versions, so we can read the older data even the datatype were changed. We should discuss this one. @Sophie-Xie

case 3:

(root@nebula) [test1]> create tag test4(col1 int,col2 int);
Execution succeeded (time spent 83118/86371 us)

Tue, 14 Sep 2021 10:47:19 CST

(root@nebula) [test1]> insert vertex test4(col1,col2) values "a":(1,2)
Execution succeeded (time spent 7692/11624 us)

Tue, 14 Sep 2021 10:47:23 CST

(root@nebula) [test1]> insert vertex test4(col1,col2) values "b":(2,3)
Execution succeeded (time spent 35314/47294 us)

Tue, 14 Sep 2021 10:47:27 CST

(root@nebula) [test1]> alter tag test4 add (col3 int)
Execution succeeded (time spent 152310/163985 us)

Tue, 14 Sep 2021 10:47:30 CST

(root@nebula) [test1]> create tag index test4_index on test4(col1,col2,col3);
Execution succeeded (time spent 118015/121077 us)

Tue, 14 Sep 2021 10:47:34 CST

(root@nebula) [test1]> rebuild tag index test4_index
[ERROR (-1009)]: SemanticError: Index test4_index not found in space test1

Tue, 14 Sep 2021 10:47:38 CST

(root@nebula) [test1]> rebuild tag index test4_index
[ERROR (-1009)]: SemanticError: Index test4_index not found in space test1

Tue, 14 Sep 2021 10:47:41 CST

(root@nebula) [test1]> rebuild tag index test4_index
+------------+
| New Job Id |
+------------+
| 33         |
+------------+
Got 1 rows (time spent 27239/30132 us)

Tue, 14 Sep 2021 10:47:48 CST

(root@nebula) [test1]> lookup on test4 where test4.col1 == 2;
Empty set (time spent 10488/13468 us)

Tue, 14 Sep 2021 10:50:39 CST

(root@nebula) [test1]> lookup on test4 where test4.col1 == 2 yield test4.col1;
Empty set (time spent 12313/14579 us)

Tue, 14 Sep 2021 11:05:37 CST

Seems like a bug which introduced in rebuild step. We could try to fix it in v2.6. @Sophie-Xie

case4: default value

The latest act should be the right one.

@Sophie-Xie
Copy link
Contributor

Sophie-Xie commented Sep 14, 2021

case 1. create a new issue #2859

case 2. create a new issue #2873

case3. pls fix it in this issue.

other, #2641

@Sophie-Xie Sophie-Xie removed their assignment Sep 14, 2021
@Sophie-Xie Sophie-Xie modified the milestones: v3.0.0, v2.6.0 Sep 14, 2021
@Sophie-Xie Sophie-Xie changed the title [upgrade known issues] case3 :alter schema with index Sep 15, 2021
@Sophie-Xie
Copy link
Contributor

There are other high priority issues to do, this issue will be later to next version.

@Sophie-Xie Sophie-Xie modified the milestones: v2.6.0, v2.7.0 Sep 18, 2021
@Sophie-Xie Sophie-Xie modified the milestones: v2.7.0, v3.0.0 Oct 15, 2021
@critical27
Copy link
Contributor

All schema problem, we'll try to fix in the version after 1230 by using Online DDL like Google F1

@Sophie-Xie
Copy link
Contributor

Talked it offline, all schema problem will fixed in 5.x.

@Sophie-Xie Sophie-Xie added the wontfix Solution: this will not be worked on recently label Apr 28, 2022
@Sophie-Xie Sophie-Xie removed this from the v5.0.0 milestone Apr 28, 2022
@wenhaocs
Copy link
Contributor

wenhaocs commented Dec 9, 2022

For case 1, we need to check all the history schemas and make sure no same properties exist when adding properties to an existing schema.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Type: something is unexpected wontfix Solution: this will not be worked on recently
Projects
None yet
Development

No branches or pull requests

6 participants