MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / handle_startup

Method handle_startup

src/adapter/src/coord/command_handler.rs:789–899  ·  view source on GitHub ↗
(
        &mut self,
        tx: oneshot::Sender<Result<StartupResponse, AdapterError>>,
        user: User,
        conn_id: ConnectionId,
        secret_key: u32,
        uuid: uuid::Uuid,
        c

Source from the content-addressed store, hash-verified

787
788 #[mz_ore::instrument(level = "debug")]
789 async fn handle_startup(
790 &mut self,
791 tx: oneshot::Sender<Result<StartupResponse, AdapterError>>,
792 user: User,
793 conn_id: ConnectionId,
794 secret_key: u32,
795 uuid: uuid::Uuid,
796 client_ip: Option<IpAddr>,
797 application_name: String,
798 notice_tx: mpsc::UnboundedSender<AdapterNotice>,
799 ) {
800 // Early return if successful, otherwise cleanup any possible state.
801 match self
802 .handle_startup_inner(&user, &conn_id, &client_ip, &notice_tx)
803 .await
804 {
805 Ok((role_id, superuser_attribute, session_defaults)) => {
806 let session_type = metrics::session_type_label_value(&user);
807 self.metrics
808 .active_sessions
809 .with_label_values(&[session_type])
810 .inc();
811 let conn = ConnMeta {
812 secret_key,
813 notice_tx,
814 drop_sinks: BTreeSet::new(),
815 pending_cluster_alters: BTreeSet::new(),
816 connected_at: self.now(),
817 user,
818 application_name,
819 uuid,
820 client_ip,
821 conn_id: conn_id.clone(),
822 authenticated_role: role_id,
823 deferred_lock: None,
824 };
825 let update = self.catalog().state().pack_session_update(&conn, Diff::ONE);
826 let update = self.catalog().state().resolve_builtin_table_update(update);
827 self.begin_session_for_statement_logging(&conn);
828 self.active_conns.insert(conn_id.clone(), conn);
829
830 // Note: Do NOT await the notify here, we pass this back to
831 // whatever requested the startup to prevent blocking startup
832 // and the Coordinator on a builtin table update.
833 let updates = vec![update];
834 // It's not a hard error if our list is missing a builtin table, but we want to
835 // make sure these two things stay in-sync.
836 if mz_ore::assert::soft_assertions_enabled() {
837 let required_tables: BTreeSet<_> = super::appends::REQUIRED_BUILTIN_TABLES
838 .iter()
839 .map(|table| self.catalog().resolve_builtin_table(*table))
840 .collect();
841 let updates_tracked = updates
842 .iter()
843 .all(|update| required_tables.contains(&update.id));
844 let all_mz_internal = super::appends::REQUIRED_BUILTIN_TABLES
845 .iter()
846 .all(|table| table.schema == MZ_INTERNAL_SCHEMA);

Callers 1

handle_commandMethod · 0.80

Calls 15

session_type_label_valueFunction · 0.85
cloneFunction · 0.85
handle_startup_innerMethod · 0.80
pack_session_updateMethod · 0.80
allMethod · 0.80
backgroundMethod · 0.80
builtin_table_updateMethod · 0.80
owned_catalogMethod · 0.80
human_versionMethod · 0.80
create_frontendMethod · 0.80

Tested by

no test coverage detected