You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by ma...@apache.org on 2024/08/28 06:44:47 UTC
(cassandra) 02/03: On upgrade, handle pre-existing tables with unexpected table ids
This is an automated email from the ASF dual-hosted git repository.
marcuse pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra.git
commit e1540fc85b1429f339e0251ecc3e048620df943a
Author: Marcus Eriksson <ma...@apache.org>
AuthorDate: Thu Aug 15 10:43:23 2024 +0200
On upgrade, handle pre-existing tables with unexpected table ids
Patch by marcuse; reviewed by Sam Tunnicliffe for CASSANDRA-19845
---
CHANGES.txt | 1 +
src/java/org/apache/cassandra/schema/DistributedSchema.java | 4 +++-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/CHANGES.txt b/CHANGES.txt
index ff1418e1d5..6b9ec7e10a 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
5.1
+ * On upgrade, handle pre-existing tables with unexpected table ids (CASSANDRA-19845)
* Reconfigure CMS before assassinate (CASSANDRA-19768)
* Warn about unqualified prepared statement only if it is select or modification statement (CASSANDRA-18322)
* Update legacy peers tables during node replacement (CASSANDRA-19782)
diff --git a/src/java/org/apache/cassandra/schema/DistributedSchema.java b/src/java/org/apache/cassandra/schema/DistributedSchema.java
index 3bac327c17..cf2919ed4d 100644
--- a/src/java/org/apache/cassandra/schema/DistributedSchema.java
+++ b/src/java/org/apache/cassandra/schema/DistributedSchema.java
@@ -130,13 +130,15 @@ public class DistributedSchema implements MetadataValue<DistributedSchema>
/**
* merges any tables in `mergeFrom` to `mergeTo` unless they already exist there.
+ *
+ * This method is only called when creating the initial cluster metadata on upgrade
*/
private static KeyspaceMetadata merged(KeyspaceMetadata mergeTo, KeyspaceMetadata mergeFrom)
{
Tables newTables = mergeTo.tables;
for (TableMetadata metadata : mergeFrom.tables)
{
- if (!newTables.containsTable(metadata.id))
+ if (!newTables.containsTable(metadata.id) && newTables.stream().noneMatch(tmd -> tmd.name.equals(metadata.name)))
newTables = newTables.with(metadata);
}
return mergeTo.withSwapped(newTables);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org