Skip to content

Commit

Permalink
Test failure: materialized_views_test.TestMaterializedViewsConsistenc…
Browse files Browse the repository at this point in the history
…y.test_multi_partition_consistent_reads_after_write

Patch by marcuse; reviewed by Sam Tunnicliffe for CASSANDRA-19056
  • Loading branch information
krummas committed Dec 1, 2023
1 parent 390d8da commit bd25c05
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/java/org/apache/cassandra/db/view/TableViews.java
Expand Up @@ -67,6 +67,7 @@
import org.apache.cassandra.schema.TableMetadata;
import org.apache.cassandra.schema.TableMetadataRef;
import org.apache.cassandra.service.StorageProxy;
import org.apache.cassandra.tcm.ClusterMetadata;
import org.apache.cassandra.utils.FBUtilities;
import org.apache.cassandra.utils.btree.BTree;
import org.apache.cassandra.utils.btree.BTreeSet;
Expand Down Expand Up @@ -172,7 +173,7 @@ public void pushViewReplicaUpdates(PartitionUpdate update, boolean writeCommitLo
{
assert update.metadata().id.equals(baseTableMetadata.id);

Collection<View> views = updatedViews(update);
Collection<View> views = updatedViews(update, ClusterMetadata.currentNullable());
if (views.isEmpty())
return;

Expand Down Expand Up @@ -391,7 +392,7 @@ public Collection<Mutation> next()
* @param updates the updates applied to the base table.
* @return the views affected by {@code updates}.
*/
public Collection<View> updatedViews(PartitionUpdate updates)
public Collection<View> updatedViews(PartitionUpdate updates, ClusterMetadata metadata)
{
List<View> matchingViews = new ArrayList<>(views.size());

Expand All @@ -400,7 +401,8 @@ public Collection<View> updatedViews(PartitionUpdate updates)
ReadQuery selectQuery = view.getReadQuery();
if (!selectQuery.selectsKey(updates.partitionKey()))
continue;

if (metadata != null && !metadata.schema.getKeyspaceMetadata(view.getDefinition().keyspace()).hasView(view.name))
continue;
matchingViews.add(view);
}
return matchingViews;
Expand Down
4 changes: 3 additions & 1 deletion src/java/org/apache/cassandra/db/view/ViewManager.java
Expand Up @@ -32,6 +32,7 @@
import org.apache.cassandra.db.*;
import org.apache.cassandra.db.partitions.*;
import org.apache.cassandra.service.StorageService;
import org.apache.cassandra.tcm.ClusterMetadata;

import static org.apache.cassandra.config.CassandraRelevantProperties.MV_ENABLE_COORDINATOR_BATCHLOG;

Expand Down Expand Up @@ -72,6 +73,7 @@ public boolean updatesAffectView(Collection<? extends IMutation> mutations, bool
if (!enableCoordinatorBatchlog && coordinatorBatchlog)
return false;

ClusterMetadata metadata = ClusterMetadata.currentNullable();
for (IMutation mutation : mutations)
{
for (PartitionUpdate update : mutation.getPartitionUpdates())
Expand All @@ -81,7 +83,7 @@ public boolean updatesAffectView(Collection<? extends IMutation> mutations, bool
if (coordinatorBatchlog && keyspace.getReplicationStrategy().getReplicationFactor().allReplicas == 1)
continue;

if (!forTable(update.metadata()).updatedViews(update).isEmpty())
if (!forTable(update.metadata()).updatedViews(update, metadata).isEmpty())
return true;
}
}
Expand Down

0 comments on commit bd25c05

Please sign in to comment.