Create a new storage controller from a client it should wrap. Note that when creating a new storage controller, you must also reconcile it with the previous state. # Panics If this function is called before [`prepare_initialization`].
(
build_info: &'static BuildInfo,
persist_location: PersistLocation,
persist_clients: Arc<PersistClientCache>,
now: NowFn,
wallclock_lag: WallclockLagFn<Timesta
| 2707 | /// # Panics |
| 2708 | /// If this function is called before [`prepare_initialization`]. |
| 2709 | pub async fn new( |
| 2710 | build_info: &'static BuildInfo, |
| 2711 | persist_location: PersistLocation, |
| 2712 | persist_clients: Arc<PersistClientCache>, |
| 2713 | now: NowFn, |
| 2714 | wallclock_lag: WallclockLagFn<Timestamp>, |
| 2715 | txns_metrics: Arc<TxnMetrics>, |
| 2716 | read_only: bool, |
| 2717 | metrics_registry: &MetricsRegistry, |
| 2718 | controller_metrics: ControllerMetrics, |
| 2719 | connection_context: ConnectionContext, |
| 2720 | txn: &dyn StorageTxn, |
| 2721 | storage_collections: Arc<dyn StorageCollections + Send + Sync>, |
| 2722 | ) -> Self { |
| 2723 | let txns_client = persist_clients |
| 2724 | .open(persist_location.clone()) |
| 2725 | .await |
| 2726 | .expect("location should be valid"); |
| 2727 | |
| 2728 | let persist_warm_task = warm_persist_state_in_background( |
| 2729 | txns_client.clone(), |
| 2730 | txn.get_collection_metadata().into_values(), |
| 2731 | ); |
| 2732 | let persist_warm_task = Some(persist_warm_task.abort_on_drop()); |
| 2733 | |
| 2734 | // This value must be already installed because we must ensure it's |
| 2735 | // durably recorded before it is used, otherwise we risk leaking persist |
| 2736 | // state. |
| 2737 | let txns_id = txn |
| 2738 | .get_txn_wal_shard() |
| 2739 | .expect("must call prepare initialization before creating storage controller"); |
| 2740 | |
| 2741 | let persist_table_worker = if read_only { |
| 2742 | let txns_write = txns_client |
| 2743 | .open_writer( |
| 2744 | txns_id, |
| 2745 | Arc::new(TxnsCodecRow::desc()), |
| 2746 | Arc::new(UnitSchema), |
| 2747 | Diagnostics { |
| 2748 | shard_name: "txns".to_owned(), |
| 2749 | handle_purpose: "follow txns upper".to_owned(), |
| 2750 | }, |
| 2751 | ) |
| 2752 | .await |
| 2753 | .expect("txns schema shouldn't change"); |
| 2754 | persist_handles::PersistTableWriteWorker::new_read_only_mode(txns_write) |
| 2755 | } else { |
| 2756 | let mut txns = TxnsHandle::open( |
| 2757 | Timestamp::MIN, |
| 2758 | txns_client.clone(), |
| 2759 | txns_client.dyncfgs().clone(), |
| 2760 | Arc::clone(&txns_metrics), |
| 2761 | txns_id, |
| 2762 | Opaque::encode(&PersistEpoch::default()), |
| 2763 | ) |
| 2764 | .await; |
| 2765 | txns.upgrade_version().await; |
| 2766 | persist_handles::PersistTableWriteWorker::new_txns(txns) |
nothing calls this directly
no test coverage detected