pub struct Controller<T: Timestamp + Lattice + Codec64 + From<EpochMillis> + TimestampManipulation> {
    build_info: &'static BuildInfo,
    state: StorageControllerState<T>,
    internal_response_queue: UnboundedReceiver<StorageResponse<T>>,
    persist_location: PersistLocation,
    persist: Arc<PersistClientCache>,
    metrics: StorageControllerMetrics,
}
Expand description

A storage controller for a storage instance.

Fields§

§build_info: &'static BuildInfo

The build information for this process.

§state: StorageControllerState<T>

The state for the storage controller. TODO(benesch): why is this a separate struct?

§internal_response_queue: UnboundedReceiver<StorageResponse<T>>

Mechanism for returning frontier advancement for tables.

§persist_location: PersistLocation

The persist location where all storage collections are being written to

§persist: Arc<PersistClientCache>

A persist client used to write to storage collections

§metrics: StorageControllerMetrics

Metrics of the Storage controller

Implementations§

true if shard is in register for shards marked for finalization.

Register shards for finalization. This must be called if you intend to finalize shards, before you perform any work to e.g. replace one shard with another.

The reasoning behind this is that we need to identify the intent to finalize a shard so we can perform the finalization on reboot if we crash and do not find the shard in use in any collection.

Removes the shard from the finalization register.

This is appropriate to do if you can guarantee that the shard has been finalized or find the shard is still in use by some collection.

Reconcile the state of SHARD_FINALIZATION_WAL with super::METADATA_COLLECTION on boot.

Determine the delta between durable_metadata and collections such that:

  • Each remap collection’s data shard is its parent collection’s remap shard.
  • No collection contains a Some value for its remap shard.

Apply this delta using Controller::upsert_collection_metadata(durable_metadata, <this function's return value>).

This approach is safe/backward compatible because:

  • Every ingestion collection previously had a remap shard
  • Every ingestion collection now has a progress collection subsource, whose data shard should be the remap shard
  • No other type of collection used their remap shards, so dropping them entirely is essentially a nop.

MIGRATION: v0.44

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.

Validate that a collection exists for all identifiers, and error if any do not.

Validate that a collection exists for all identifiers, and error if any do not.

Return the since frontier at which we can read from all the given collections.

The outer error is a potentially recoverable internal error, while the inner error is appropriate to return to the adapter.

Install read capabilities on the given storage_dependencies.

Removes read holds that were previously acquired via install_read_capabilities.

Panics

This panics if there are no read capabilities at capability for all depended-upon collections.

Opens a write and critical since handles for the given shard.

This will halt! the process if we cannot successfully acquire a critical handle with our current epoch.

Effectively truncates the data_shard associated with global_id effective as of the system time.

Panics
  • If id does not belong to a collection or is not registered as a managed collection.

Append updates to the data_shard associated with global_id effective as of the system time.

Panics
  • If id is not registered as a managed collection.

Initializes the data expressing which global IDs correspond to which shards. Necessary because we cannot write any of these mappings that we discover before the shard mapping collection exists.

Panics
  • If IntrospectionType::ShardMapping is not associated with a GlobalId in self.state.introspection_ids.
  • If IntrospectionType::ShardMapping’s GlobalId is not registered as a managed collection.

Writes a new global ID, shard ID pair to the appropriate collection.

However, data is written iff we know of the GlobalId of the IntrospectionType::ShardMapping collection; in other cases, data is dropped on the floor. In these cases, the data is later written by Self::initialize_shard_mapping.

Panics
  • If self.state.collections does not have an entry for global_id.
  • If IntrospectionType::ShardMapping’s GlobalId is not registered as a managed collection.

Updates the on-disk and in-memory representation of DurableCollectionMetadata (i.e. KV pairs in METADATA_COLLECTION on-disk and all_current_metadata as its in-memory representation) to include that of upsert_state, i.e. upserting the KV pairs in upsert_state into in all_current_metadata, as well as METADATA_COLLECTION.

Any shards no longer referenced after the upsert will be finalized.

Note that this function expects to be called:

  • While no source is currently using the shards identified in the current metadata.
  • Before any sources begins using the shards identified in new_metadata.

Closes the identified shards from further reads or writes.

Trait Implementations§

Formats the value using the given formatter. Read more

Drops the read capability for the sinks and allows their resources to be reclaimed.

Marks the end of any initialization commands. Read more
Update storage configuration.
Acquire an immutable reference to the collection state, should it exist.
Acquire a mutable reference to the collection state, should it exist.
Acquire an iterator over all collection states.
Creates a storage instance with the specified ID. Read more
Drops the storage instance with the given ID. Read more
Connects the storage instance to the specified replica. Read more
Migrate any storage controller state from previous versions to this version’s expectations. Read more
Create the sources described in the individual CreateSourceCommand commands. Read more
Acquire an immutable reference to the export state, should it exist.
Acquire a mutable reference to the export state, should it exist.
Notify the storage controller to prepare for an export to be created
Cancel the pending export
Create the sinks described by the ExportDescription.
Drops the read capability for the sources and allows their resources to be reclaimed.
Drops the read capability for the sources and allows their resources to be reclaimed. Read more
Drops the read capability for the sinks and allows their resources to be reclaimed. Read more
Append updates into the local input named id and advance its upper to upper. Read more
Returns the snapshot of the contents of the local input named id at as_of.
Assigns a read policy to specific identifiers. Read more
Ingests write frontier updates for collections that this controller maintains and potentially generates updates to read capabilities, which are passed on to StorageController::update_read_capabilities. Read more
Applies updates and sends any appropriate compaction command.
Waits until the controller is ready to process a response. Read more
Processes the work queued by StorageController::ready. Read more
Signal to the controller that the adapter has populated all of its initial state and the controller can reconcile (i.e. drop) any unclaimed resources.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Attaches the current Context to this type, returning a WithContext wrapper. Read more
Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Wrap the input message T in a tonic::Request
The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
Should always be Self
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more