-
Notifications
You must be signed in to change notification settings - Fork 591
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
feat: add sql migration script and related ci tests #16000
Merged
Merged
Changes from 21 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
61f91cc
feat: init version for catalogs
yezizp2012 d572c5c
rewrite conn
yezizp2012 1e199e1
Merge branch 'main' into feat/migration-etcd-2-sql
yezizp2012 93c49d6
support hummock and compaction
yezizp2012 4108697
fix serveral corner cases
yezizp2012 1cb3b7f
Merge branch 'main' into feat/migration-etcd-2-sql
yezizp2012 a0ba4bb
fix mysql syntax
yezizp2012 802754d
minor changes
yezizp2012 17de023
Merge branch 'main' into feat/migration-etcd-2-sql
yezizp2012 03e40fe
revert comment
yezizp2012 c80052e
add ci tests
yezizp2012 7923439
chmod
yezizp2012 8c66e35
fix
yezizp2012 dda6608
fix test script
yezizp2012 6cbedaf
fix
yezizp2012 33a6fd9
fix slt
yezizp2012 4aafb05
fix slt
yezizp2012 377fd80
fix slt
yezizp2012 ac1d6f7
wait for recovery
yezizp2012 5fe4986
Merge branch 'main' into feat/migration-etcd-2-sql
yezizp2012 cd4d076
Merge branch 'main' into feat/migration-etcd-2-sql
yezizp2012 fb2e799
Merge branch 'main' into feat/migration-etcd-2-sql
yezizp2012 57da886
resolve comments, add cluster version info and fix some corner cases
yezizp2012 2152109
support custom
yezizp2012 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Exits as soon as any line fails. | ||
set -euo pipefail | ||
|
||
export RW_PREFIX=$PWD/.risingwave | ||
export RW_PREFIX_DATA=$RW_PREFIX/data | ||
|
||
source ci/scripts/common.sh | ||
|
||
wait_for_recovery() { | ||
set +e | ||
timeout 20s bash -c ' | ||
while true; do | ||
echo "Polling every 1s to check if the recovery is complete for 20s" | ||
if psql -h localhost -p 4566 -d dev -U root -c "FLUSH;" </dev/null | ||
then exit 0; | ||
else sleep 1; | ||
fi | ||
done | ||
' | ||
STATUS=$? | ||
set -e | ||
if [[ $STATUS -ne 0 ]]; then | ||
echo "Cluster failed to get recovered: $STATUS" | ||
exit 1 | ||
else | ||
echo "Cluster is recovered" | ||
fi | ||
} | ||
|
||
while getopts 'p:' opt; do | ||
case ${opt} in | ||
p ) | ||
profile=$OPTARG | ||
;; | ||
\? ) | ||
echo "Invalid Option: -$OPTARG" 1>&2 | ||
exit 1 | ||
;; | ||
: ) | ||
echo "Invalid option: $OPTARG requires an argument" 1>&2 | ||
;; | ||
esac | ||
done | ||
shift $((OPTIND -1)) | ||
|
||
download_and_prepare_rw "$profile" common | ||
|
||
echo "--- starting risingwave cluster, ci-1cn-1fe-with-recovery" | ||
RUST_LOG="info,risingwave_stream=info,risingwave_batch=info,risingwave_storage=info" \ | ||
cargo make ci-start ci-1cn-1fe-with-recovery | ||
|
||
echo "--- init cluster with some data & DDL" | ||
sqllogictest -d dev -h localhost -p 4566 './e2e_test/sql_migration/prepare.slt' | ||
|
||
echo "--- kill cluster" | ||
cargo make ci-kill | ||
|
||
echo "--- restart etcd" | ||
cargo make dev ci-meta-etcd-for-migration | ||
|
||
echo "--- run migration" | ||
mkdir -p "${RW_PREFIX_DATA}/sqlite/" | ||
./target/debug/risingwave risectl \ | ||
meta \ | ||
migration \ | ||
--etcd-endpoints localhost:2388 \ | ||
--sql-endpoint sqlite://"${RW_PREFIX_DATA}/sqlite/metadata.db"\?mode=rwc \ | ||
-f | ||
|
||
echo "--- kill etcd" | ||
cargo make ci-kill | ||
|
||
echo "--- starting risingwave cluster, meta-1cn-1fe-sqlite" | ||
cargo make dev meta-1cn-1fe-sqlite | ||
|
||
echo "--- wait for recovery" | ||
wait_for_recovery | ||
|
||
echo "--- run check" | ||
sqllogictest -d dev -h localhost -p 4566 './e2e_test/sql_migration/check.slt' | ||
|
||
echo "--- kill cluster" | ||
cargo make kill | ||
|
||
echo "--- clean data" | ||
cargo make clean-data | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
statement ok | ||
SET RW_IMPLICIT_FLUSH TO true; | ||
|
||
query T rowsort | ||
show databases; | ||
---- | ||
db1 | ||
dev | ||
|
||
query T rowsort | ||
show schemas; | ||
---- | ||
information_schema | ||
pg_catalog | ||
public | ||
rw_catalog | ||
schema1 | ||
|
||
query T rowsort | ||
select name, relation_type from rw_relations where relation_type != 'system table' AND relation_type != 'view'; | ||
---- | ||
ddl_subscription_table subscription | ||
idx1 index | ||
m_simple table | ||
mv1 materialized view | ||
mv2 materialized view | ||
s_simple_1 sink | ||
sink sink | ||
src source | ||
t1 table | ||
t_simple table | ||
|
||
query T | ||
show views; | ||
---- | ||
v1 | ||
|
||
query T | ||
select name, type_, provider from rw_connections; | ||
---- | ||
conn0 MOCK PRIVATELINK | ||
|
||
query TTTTT | ||
show functions; | ||
---- | ||
int_42 (empty) integer javascript NULL | ||
|
||
statement ok | ||
insert into t1 select * from generate_series(1, 1000); | ||
|
||
query I | ||
select count(*) from t1; | ||
---- | ||
2000 | ||
|
||
statement ok | ||
create materialized view mv3 as select * from mv2; | ||
|
||
statement ok | ||
REVOKE ALL PRIVILEGES ON ALL TABLES IN SCHEMA schema1 FROM user1; | ||
|
||
statement error Permission denied | ||
drop source src; | ||
|
||
statement ok | ||
drop source src cascade; | ||
|
||
statement ok | ||
drop connection conn0; | ||
|
||
statement ok | ||
drop function int_42; | ||
|
||
statement ok | ||
drop sink s_simple_1; | ||
|
||
statement error Permission denied | ||
drop table t1; | ||
|
||
statement ok | ||
drop table t1 cascade; | ||
|
||
statement ok | ||
drop table t_simple; | ||
|
||
statement ok | ||
drop table m_simple; | ||
|
||
statement ok | ||
drop user user1; | ||
|
||
statement ok | ||
drop schema schema1; | ||
|
||
statement ok | ||
drop database db1; | ||
|
||
query T | ||
select name, relation_type from rw_relations where relation_type != 'system table' AND relation_type != 'view'; | ||
---- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
statement ok | ||
SET RW_IMPLICIT_FLUSH TO true; | ||
|
||
statement ok | ||
create database db1; | ||
|
||
statement ok | ||
create schema schema1; | ||
|
||
statement ok | ||
create source src (v int) with ( | ||
connector = 'datagen', | ||
fields.v.kind = 'sequence', | ||
fields.v.start = '1', | ||
fields.v.end = '10', | ||
datagen.rows.per.second='15', | ||
datagen.split.num = '1' | ||
) FORMAT PLAIN ENCODE JSON; | ||
|
||
statement ok | ||
create table t1(v1 int); | ||
|
||
statement ok | ||
create materialized view mv1 as select * from t1; | ||
|
||
statement ok | ||
create materialized view mv2 as select * from src; | ||
|
||
statement ok | ||
create view v1 as select * from mv1; | ||
|
||
statement ok | ||
CREATE SINK sink FROM mv2 WITH (connector='blackhole'); | ||
|
||
statement ok | ||
create user user1; | ||
|
||
statement ok | ||
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA schema1 TO user1; | ||
|
||
statement ok | ||
CREATE CONNECTION conn0 WITH (type = 'privatelink', provider = 'mock'); | ||
|
||
statement ok | ||
create index idx1 on t1(v1); | ||
|
||
statement ok | ||
create table t_simple (v1 int, v2 int); | ||
|
||
statement ok | ||
create table m_simple (v1 int primary key, v2 int); | ||
|
||
statement ok | ||
create sink s_simple_1 into m_simple as select v1, v2 from t_simple; | ||
|
||
statement ok | ||
create subscription ddl_subscription_table from mv2 with(retention = '1D'); | ||
|
||
statement ok | ||
insert into t1 select * from generate_series(1, 1000); | ||
|
||
statement ok | ||
create function int_42() returns int language javascript as $$ | ||
return 42; | ||
$$; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,18 +24,28 @@ futures = { version = "0.3", default-features = false, features = ["alloc"] } | |
hex = "0.4" | ||
inquire = "0.7.0" | ||
itertools = "0.12" | ||
memcomparable = "0.2" | ||
prost = { workspace = true } | ||
regex = "1.10.0" | ||
risingwave_common = { workspace = true } | ||
risingwave_connector = { workspace = true } | ||
risingwave_frontend = { workspace = true } | ||
risingwave_hummock_sdk = { workspace = true } | ||
risingwave_meta = { workspace = true } | ||
risingwave_meta_model_migration = { workspace = true } | ||
risingwave_meta_model_v2 = { workspace = true } | ||
risingwave_object_store = { workspace = true } | ||
risingwave_pb = { workspace = true } | ||
risingwave_rpc_client = { workspace = true } | ||
risingwave_storage = { workspace = true } | ||
risingwave_stream = { workspace = true } | ||
sea-orm = { version = "0.12.14", features = [ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we make it a workspace dependency? |
||
"sqlx-mysql", | ||
"sqlx-postgres", | ||
"sqlx-sqlite", | ||
"runtime-tokio-native-tls", | ||
"macros", | ||
] } | ||
serde = "1" | ||
serde_json = "1" | ||
serde_yaml = "0.9.25" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It appears to be hard to cover all metadata here. 😕 For example, the system parameters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed 😕 . I haven't thought of a better way to cover all the metadata yet, so I can only add them on a case-by-case basis for now. I will add the system parameters as well.