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

feat(meta): support drop creating materialized views for v2 backend #17503

Merged
merged 57 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from 53 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
6397ec9
update creating catalogs
kwannoel Jun 27, 2024
2b825e3
decouple finish create table and finish create mv
kwannoel Jun 27, 2024
0082554
refactor cancel
kwannoel Jun 27, 2024
fd6ff98
fix
kwannoel Jun 27, 2024
3714af9
handle cancel path in drop
kwannoel Jun 27, 2024
d3d4605
handle delete catalog to fe after cancel
kwannoel Jun 27, 2024
ba91e6c
filter out creating tables by default
kwannoel Jun 27, 2024
cbd78a6
refactor created table getters + only make creating tables visible in…
kwannoel Jun 27, 2024
b9789a9
report catalog in v2, left internal tables
kwannoel Jun 27, 2024
2dfb3e5
only commit internal tables
kwannoel Jun 27, 2024
044525f
fix v1
kwannoel Jun 28, 2024
7f51256
Revert "only commit internal tables"
kwannoel Jun 28, 2024
6a47d92
add fixme for clean up stream jobs + return all tables on frontend su…
kwannoel Jun 28, 2024
293f034
fix clean dirty tables for v1
kwannoel Jun 28, 2024
33d94ce
notify internal table catalog for v2
kwannoel Jun 28, 2024
99427d2
provide create job obj in finish_streaming_job
kwannoel Jun 28, 2024
884793c
Revert "report catalog in v2, left internal tables"
kwannoel Jun 28, 2024
339f089
Revert "notify internal table catalog for v2"
kwannoel Jun 28, 2024
c71f181
Revert "provide create job obj in finish_streaming_job"
kwannoel Jun 28, 2024
8db729c
fix test utils
kwannoel Jul 2, 2024
2753537
fix ut
kwannoel Jul 2, 2024
09b8f88
rename get_table to get_any_table
kwannoel Jul 3, 2024
ba911e4
fix log
kwannoel Jul 3, 2024
45ceed0
fix docs
kwannoel Jul 3, 2024
a188fb3
rm fixme
kwannoel Jul 4, 2024
5bd5fc4
rename
kwannoel Jul 4, 2024
bd4f20a
Revert "Revert "report catalog in v2, left internal tables""
kwannoel Jun 28, 2024
cdcadf2
Revert "Revert "notify internal table catalog for v2""
kwannoel Jun 28, 2024
bcba4aa
Revert "Revert "provide create job obj in finish_streaming_job""
kwannoel Jun 28, 2024
5bfcd49
refactor notification functionality
kwannoel Jul 1, 2024
d4445bc
report deleted dirty jobs catalog to fe
kwannoel Jul 1, 2024
d92e515
refactor logging out
kwannoel Jul 1, 2024
bef1421
notify on create
kwannoel Jul 1, 2024
b85f25f
notify delete for relation group
kwannoel Jul 1, 2024
c3c52ec
change add to update for finish jobs
kwannoel Jul 1, 2024
3a4ef73
start create ddl (internal tables)
kwannoel Jul 1, 2024
b27ef7c
fix create catalog txn deadlock
kwannoel Jul 1, 2024
80d7b12
handle fragment update
kwannoel Jul 1, 2024
b987025
fmt
kwannoel Jul 1, 2024
2ac2a9e
fix
kwannoel Jul 1, 2024
5fc93bb
fix
kwannoel Jul 1, 2024
ef45d8b
fix index test
kwannoel Jul 2, 2024
cd34f36
fmt
kwannoel Jul 2, 2024
2df055b
add e2e test
kwannoel Jul 2, 2024
c3906f6
delete only after querying objects to cancel
kwannoel Jul 2, 2024
8b69519
fix
kwannoel Jul 2, 2024
4d125d5
permit recovery
kwannoel Jul 2, 2024
db45d28
use label
kwannoel Jul 2, 2024
f88a5b4
Merge branch 'main' into kwannoel/mark-creating-v2
kwannoel Jul 4, 2024
cb1325c
fix
kwannoel Jul 4, 2024
60f4317
Merge branch 'main' into kwannoel/mark-creating-v2
kwannoel Jul 5, 2024
e2b75b3
allow adhoc recovery when disable_recovery set
kwannoel Jul 6, 2024
fcf50c2
revert refactor of oid to object
kwannoel Jul 8, 2024
ef85fde
make single node compat with risedev psql
kwannoel Jul 15, 2024
f62d7e6
fix path
kwannoel Jul 15, 2024
3eb1c6e
fix
kwannoel Jul 16, 2024
99186bf
Merge remote-tracking branch 'origin/main' into kwannoel/mark-creatin…
kwannoel Jul 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ci/scripts/run-e2e-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ cluster_stop
echo "--- e2e, $mode, batch"
RUST_LOG="info,risingwave_stream=info,risingwave_batch=info,risingwave_storage=info" \
cluster_start
sqllogictest -p 4566 -d dev './e2e_test/ddl/**/*.slt' --junit "batch-ddl-${profile}"
sqllogictest -p 4566 -d dev './e2e_test/ddl/**/*.slt' --junit "batch-ddl-${profile}" --label "can-use-recover"
if [[ "$mode" != "single-node" ]]; then
sqllogictest -p 4566 -d dev './e2e_test/background_ddl/basic.slt' --junit "batch-ddl-${profile}"
fi
Expand Down
76 changes: 76 additions & 0 deletions e2e_test/ddl/drop/drop_creating_mv.slt
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
statement ok
create table t(v1 int);

statement ok
insert into t select * from generate_series(1, 10000);

statement ok
flush;

statement ok
set streaming_rate_limit=1;

############## Test drop foreground mv
onlyif can-use-recover
system ok
psql -h localhost -p 4566 -d dev -U root -c 'create materialized view m1 as select * from t;' &
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't work under parallelism execution since the database name won't be dev anymore. 😕

Copy link
Contributor Author

@kwannoel kwannoel Jul 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parallel execution won't run this test. Because trigger recovery in one test thread will affect the execution of another test thread.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can use ./risedev psql -c


onlyif can-use-recover
sleep 5s

onlyif can-use-recover
statement ok
drop materialized view m1;

############## Test drop background mv BEFORE recovery
statement ok
set background_ddl=true;

onlyif can-use-recover
statement ok
create materialized view m1 as select * from t;

onlyif can-use-recover
sleep 5s

onlyif can-use-recover
statement ok
drop materialized view m1;

############## Test drop background mv AFTER recovery
statement ok
set background_ddl=true;

onlyif can-use-recover
statement ok
create materialized view m1 as select * from t;

onlyif can-use-recover
sleep 5s

onlyif can-use-recover
statement ok
recover;

onlyif can-use-recover
sleep 10s

onlyif can-use-recover
statement ok
drop materialized view m1;

############## Make sure the mv can still be successfully created later.
statement ok
set streaming_rate_limit=default;

statement ok
set background_ddl=false;

statement ok
create materialized view m1 as select * from t;

statement ok
drop materialized view m1;

statement ok
drop table t;
19 changes: 15 additions & 4 deletions src/batch/src/worker_manager/worker_node_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use std::time::Duration;

use rand::seq::SliceRandom;
use risingwave_common::bail;
use risingwave_common::catalog::OBJECT_ID_PLACEHOLDER;
use risingwave_common::hash::{WorkerSlotId, WorkerSlotMapping};
use risingwave_common::vnode_mapping::vnode_placement::place_vnode;
use risingwave_pb::common::{WorkerNode, WorkerType};
Expand Down Expand Up @@ -219,10 +220,20 @@ impl WorkerNodeManager {

pub fn remove_streaming_fragment_mapping(&self, fragment_id: &FragmentId) {
let mut guard = self.inner.write().unwrap();
guard
.streaming_fragment_vnode_mapping
.remove(fragment_id)
.unwrap();

let res = guard.streaming_fragment_vnode_mapping.remove(fragment_id);
match &res {
Some(_) => {}
None if OBJECT_ID_PLACEHOLDER == *fragment_id => {
// Do nothing for placeholder fragment.
}
None => {
panic!(
"Streaming vnode mapping not found for fragment_id: {}",
fragment_id
)
}
};
}

/// Returns fragment's vnode mapping for serving.
Expand Down
5 changes: 1 addition & 4 deletions src/frontend/src/catalog/schema_catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,7 @@ impl SchemaCatalog {
pub fn create_index(&mut self, prost: &PbIndex) {
let name = prost.name.clone();
let id = prost.id.into();

let index_table = self
.get_created_table_by_id(&prost.index_table_id.into())
.unwrap();
let index_table = self.get_table_by_id(&prost.index_table_id.into()).unwrap();
let primary_table = self
.get_created_table_by_id(&prost.primary_table_id.into())
.unwrap();
Expand Down
30 changes: 13 additions & 17 deletions src/meta/src/barrier/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -819,24 +819,20 @@ impl GlobalBarrierManager {
self.context.tracker.lock().await.abort_all(&err);
self.checkpoint_control.clear_on_err(&err).await;

if self.enable_recovery {
kwannoel marked this conversation as resolved.
Show resolved Hide resolved
self.context
.set_status(BarrierManagerStatus::Recovering(RecoveryReason::Adhoc));
let latest_snapshot = self.context.hummock_manager.latest_snapshot();
let prev_epoch = TracedEpoch::new(latest_snapshot.committed_epoch.into()); // we can only recover from the committed epoch
let span = tracing::info_span!(
"adhoc_recovery",
error = %err.as_report(),
prev_epoch = prev_epoch.value().0
);
self.context
.set_status(BarrierManagerStatus::Recovering(RecoveryReason::Adhoc));
let latest_snapshot = self.context.hummock_manager.latest_snapshot();
let prev_epoch = TracedEpoch::new(latest_snapshot.committed_epoch.into()); // we can only recover from the committed epoch
let span = tracing::info_span!(
"adhoc_recovery",
error = %err.as_report(),
prev_epoch = prev_epoch.value().0
);

// No need to clean dirty tables for barrier recovery,
// The foreground stream job should cleanup their own tables.
self.recovery(None).instrument(span).await;
self.context.set_status(BarrierManagerStatus::Running);
} else {
panic!("failed to execute barrier: {}", err.as_report());
}
// No need to clean dirty tables for barrier recovery,
// The foreground stream job should cleanup their own tables.
self.recovery(None).instrument(span).await;
self.context.set_status(BarrierManagerStatus::Running);
}
}

Expand Down
Loading
Loading