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

coord: initialize read policy for log indexes #14025

Merged
merged 2 commits into from
Aug 2, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
4 changes: 2 additions & 2 deletions src/adapter/src/catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3165,7 +3165,7 @@ impl<S: Append> Catalog<S> {
Op::CreateComputeInstance {
name,
config,
introspection_sources,
introspection_source_indexes: introspection_sources,
} => {
if is_reserved_name(&name) {
return Err(AdapterError::Catalog(Error::new(
Expand Down Expand Up @@ -4030,7 +4030,7 @@ pub enum Op {
CreateComputeInstance {
name: String,
config: Option<ComputeInstanceIntrospectionConfig>,
introspection_sources: Vec<(&'static BuiltinLog, GlobalId)>,
introspection_source_indexes: Vec<(&'static BuiltinLog, GlobalId)>,
},
CreateComputeInstanceReplica {
name: String,
Expand Down
16 changes: 14 additions & 2 deletions src/adapter/src/coord/sequencer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -579,15 +579,19 @@ impl<S: Append + 'static> Coordinator<S> {
}: CreateComputeInstancePlan,
) -> Result<ExecuteResponse, AdapterError> {
tracing::debug!("sequence_create_compute_instance");
let introspection_sources = if compute_instance_config.is_some() {
let introspection_source_indexes = if compute_instance_config.is_some() {
self.catalog.allocate_introspection_source_indexes().await
} else {
Vec::new()
};
let introspection_source_index_ids: Vec<_> = introspection_source_indexes
.iter()
.map(|(_, id)| *id)
.collect();
let mut ops = vec![catalog::Op::CreateComputeInstance {
name: name.clone(),
config: compute_instance_config.clone(),
introspection_sources,
introspection_source_indexes,
}];

let azs = self.catalog.state().availability_zones();
Expand Down Expand Up @@ -690,6 +694,14 @@ impl<S: Append + 'static> Coordinator<S> {
.unwrap();
}

if !introspection_source_index_ids.is_empty() {
self.initialize_compute_read_policies(
introspection_source_index_ids,
instance.id,
DEFAULT_LOGICAL_COMPACTION_WINDOW_MS,
)
.await;
}
if !introspection_collection_ids.is_empty() {
self.initialize_storage_read_policies(
introspection_collection_ids,
Expand Down
29 changes: 29 additions & 0 deletions test/sqllogictest/cluster_log_compaction.slt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright Materialize, Inc. and contributors. All rights reserved.
#
# Use of this software is governed by the Business Source License
# included in the LICENSE file at the root of this repository.
#
# As of the Change Date specified in that file, in accordance with
# the Business Source License, use of this software will be governed
# by the Apache License, Version 2.0.

# Ensure correct log creation on `CREATE CLUSTER` initializes read policies for introspection source indexes.

mode cockroach

statement ok
CREATE CLUSTER c1 REPLICAS (r (SIZE '1'));

statement ok
SET CLUSTER TO c1;

statement ok
BEGIN

# Transaction will force a read hold on this index.
query T rowsort
SELECT * FROM mz_arrangement_batches_internal_2;
----

statement ok
COMMIT