@@ -20,6 +20,7 @@ use risingwave_common::hash::ParallelUnitMapping;
20
20
use risingwave_common:: system_param:: local_manager:: LocalSystemParamsManagerRef ;
21
21
use risingwave_common_service:: observer_manager:: { ObserverState , SubscribeFrontend } ;
22
22
use risingwave_pb:: common:: WorkerNode ;
23
+ use risingwave_pb:: meta:: relation:: RelationInfo ;
23
24
use risingwave_pb:: meta:: subscribe_response:: { Info , Operation } ;
24
25
use risingwave_pb:: meta:: { FragmentParallelUnitMapping , SubscribeResponse } ;
25
26
use tokio:: sync:: watch:: Sender ;
@@ -49,14 +50,7 @@ impl ObserverState for FrontendObserverNode {
49
50
} ;
50
51
51
52
match info. to_owned ( ) {
52
- Info :: Database ( _)
53
- | Info :: Schema ( _)
54
- | Info :: Table ( _)
55
- | Info :: Source ( _)
56
- | Info :: Index ( _)
57
- | Info :: Sink ( _)
58
- | Info :: Function ( _)
59
- | Info :: View ( _) => {
53
+ Info :: Database ( _) | Info :: Schema ( _) | Info :: RelationGroup ( _) => {
60
54
self . handle_catalog_notification ( resp) ;
61
55
}
62
56
Info :: Node ( node) => {
@@ -193,52 +187,76 @@ impl FrontendObserverNode {
193
187
Operation :: Delete => catalog_guard. drop_schema ( schema. database_id , schema. id ) ,
194
188
_ => panic ! ( "receive an unsupported notify {:?}" , resp) ,
195
189
} ,
196
- Info :: Table ( table) => match resp. operation ( ) {
197
- Operation :: Add => catalog_guard. create_table ( table) ,
198
- Operation :: Delete => {
199
- catalog_guard. drop_table ( table. database_id , table. schema_id , table. id . into ( ) )
200
- }
201
- Operation :: Update => catalog_guard. update_table ( table) ,
202
- _ => panic ! ( "receive an unsupported notify {:?}" , resp) ,
203
- } ,
204
- Info :: Source ( source) => match resp. operation ( ) {
205
- Operation :: Add => catalog_guard. create_source ( source) ,
206
- Operation :: Delete => {
207
- catalog_guard. drop_source ( source. database_id , source. schema_id , source. id )
208
- }
209
- _ => panic ! ( "receive an unsupported notify {:?}" , resp) ,
210
- } ,
211
- Info :: Sink ( sink) => match resp. operation ( ) {
212
- Operation :: Add => catalog_guard. create_sink ( sink) ,
213
- Operation :: Delete => {
214
- catalog_guard. drop_sink ( sink. database_id , sink. schema_id , sink. id )
215
- }
216
- _ => panic ! ( "receive an unsupported notify {:?}" , resp) ,
217
- } ,
218
- Info :: Index ( index) => match resp. operation ( ) {
219
- Operation :: Add => catalog_guard. create_index ( index) ,
220
- Operation :: Delete => {
221
- catalog_guard. drop_index ( index. database_id , index. schema_id , index. id . into ( ) )
222
- }
223
- Operation :: Update => catalog_guard. update_index ( index) ,
224
- _ => panic ! ( "receive an unsupported notify {:?}" , resp) ,
225
- } ,
226
- Info :: View ( view) => match resp. operation ( ) {
227
- Operation :: Add => catalog_guard. create_view ( view) ,
228
- Operation :: Delete => {
229
- catalog_guard. drop_view ( view. database_id , view. schema_id , view. id )
190
+ Info :: RelationGroup ( relation_group) => {
191
+ for relation in & relation_group. relations {
192
+ let Some ( relation) = relation. relation_info . as_ref ( ) else {
193
+ continue ;
194
+ } ;
195
+ match relation {
196
+ RelationInfo :: Table ( table) => match resp. operation ( ) {
197
+ Operation :: Add => catalog_guard. create_table ( table) ,
198
+ Operation :: Delete => catalog_guard. drop_table (
199
+ table. database_id ,
200
+ table. schema_id ,
201
+ table. id . into ( ) ,
202
+ ) ,
203
+ Operation :: Update => {
204
+ let old_table =
205
+ catalog_guard. get_table_by_id ( & table. id . into ( ) ) . unwrap ( ) ;
206
+ catalog_guard. update_table ( table) ;
207
+ assert ! ( old_table. fragment_id != table. fragment_id) ;
208
+ // FIXME: the frontend node delete its fragment for the update
209
+ // operation by itself.
210
+ self . worker_node_manager
211
+ . remove_fragment_mapping ( & old_table. fragment_id ) ;
212
+ }
213
+ _ => panic ! ( "receive an unsupported notify {:?}" , resp) ,
214
+ } ,
215
+ RelationInfo :: Source ( source) => match resp. operation ( ) {
216
+ Operation :: Add => catalog_guard. create_source ( source) ,
217
+ Operation :: Delete => catalog_guard. drop_source (
218
+ source. database_id ,
219
+ source. schema_id ,
220
+ source. id ,
221
+ ) ,
222
+ _ => panic ! ( "receive an unsupported notify {:?}" , resp) ,
223
+ } ,
224
+ RelationInfo :: Sink ( sink) => match resp. operation ( ) {
225
+ Operation :: Add => catalog_guard. create_sink ( sink) ,
226
+ Operation :: Delete => {
227
+ catalog_guard. drop_sink ( sink. database_id , sink. schema_id , sink. id )
228
+ }
229
+ _ => panic ! ( "receive an unsupported notify {:?}" , resp) ,
230
+ } ,
231
+ RelationInfo :: Index ( index) => match resp. operation ( ) {
232
+ Operation :: Add => catalog_guard. create_index ( index) ,
233
+ Operation :: Delete => catalog_guard. drop_index (
234
+ index. database_id ,
235
+ index. schema_id ,
236
+ index. id . into ( ) ,
237
+ ) ,
238
+ Operation :: Update => catalog_guard. update_index ( index) ,
239
+ _ => panic ! ( "receive an unsupported notify {:?}" , resp) ,
240
+ } ,
241
+ RelationInfo :: View ( view) => match resp. operation ( ) {
242
+ Operation :: Add => catalog_guard. create_view ( view) ,
243
+ Operation :: Delete => {
244
+ catalog_guard. drop_view ( view. database_id , view. schema_id , view. id )
245
+ }
246
+ _ => panic ! ( "receive an unsupported notify {:?}" , resp) ,
247
+ } ,
248
+ RelationInfo :: Function ( function) => match resp. operation ( ) {
249
+ Operation :: Add => catalog_guard. create_function ( function) ,
250
+ Operation :: Delete => catalog_guard. drop_function (
251
+ function. database_id ,
252
+ function. schema_id ,
253
+ function. id . into ( ) ,
254
+ ) ,
255
+ _ => panic ! ( "receive an unsupported notify {:?}" , resp) ,
256
+ } ,
257
+ }
230
258
}
231
- _ => panic ! ( "receive an unsupported notify {:?}" , resp) ,
232
- } ,
233
- Info :: Function ( function) => match resp. operation ( ) {
234
- Operation :: Add => catalog_guard. create_function ( function) ,
235
- Operation :: Delete => catalog_guard. drop_function (
236
- function. database_id ,
237
- function. schema_id ,
238
- function. id . into ( ) ,
239
- ) ,
240
- _ => panic ! ( "receive an unsupported notify {:?}" , resp) ,
241
- } ,
259
+ }
242
260
_ => unreachable ! ( ) ,
243
261
}
244
262
assert ! (
0 commit comments