smiklosovic commented on code in PR #4661:
URL: https://github.com/apache/cassandra/pull/4661#discussion_r2965497758


##########
src/java/org/apache/cassandra/service/snapshot/SnapshotLoader.java:
##########
@@ -149,7 +154,37 @@ private void loadSnapshotFromDir(Matcher 
snapshotDirMatcher, Path snapshotDir)
         {
             String keyspaceName = snapshotDirMatcher.group("keyspace");
             String tableName = snapshotDirMatcher.group("tableName");
-            UUID tableId = parseUUID(snapshotDirMatcher.group("tableId"));
+            final UUID tableId;
+            if (snapshotDirMatcher.group("tableId") == null)
+            {
+                logger.debug("Snapshot directory without tableId found 
(pre-2.1 format): {}", snapshotDir);
+                // If we don't have a tableId in folder name (e.g pre 2.1 
created table)
+                // Then attempt to get tableId from CFS on startup
+                // falling back to null is fine as it still yields a unique 
result in buildSnapshotId for pre-2.1 table
+                if (Keyspace.isInitialized() && 
Schema.instance.getKeyspaceMetadata(keyspaceName) != null)
+                {
+                    ColumnFamilyStore cfs = 
ColumnFamilyStore.getIfExists(keyspaceName, tableName);
+                    tableId = cfs != null && cfs.metadata.id != null
+                              ? cfs.metadata.id.asUUID()
+                              : null;
+
+                    if (tableId == null)
+                    {
+                        logger.warn("Snapshot directory without tableId found 
(pre-2.1 format) " +
+                                    "unable to initialize tableId from cfs 
defaulting to null {}", snapshotDir);
+                    }
+                }
+                else
+                {
+                    logger.warn("Snapshot directory without tableId found 
(pre-2.1 format) " +
+                                "Keyspace not initliazed or missing schema 
unable to initialize tableId default to null {}", snapshotDir);

Review Comment:
   Could you add a dot (".") between these two sentences? I am maybe too 
pedantic but this reads better
   
   Snapshot directory without table id found (pre-2.1 format), keyspace is not 
initialized or there is a schema missing, defaulting to null, snapshot dir: {}
   
   You have also a typo in "initliazed".



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to