mike-tr-adamson commented on code in PR #2689:
URL: https://github.com/apache/cassandra/pull/2689#discussion_r1332843897
##########
src/java/org/apache/cassandra/io/sstable/format/SSTableWriter.java:
##########
@@ -98,11 +107,63 @@ protected SSTableWriter(Builder<?, ?> builder,
LifecycleNewTracker lifecycleNewT
this.isTransient = builder.isTransientSSTable();
this.metadataCollector = builder.getMetadataCollector();
this.header = builder.getSerializationHeader();
- this.observers = builder.getFlushObservers();
this.mmappedRegionsCache = builder.getMmappedRegionsCache();
this.lifecycleNewTracker = lifecycleNewTracker;
+ ArrayList<SSTableFlushObserver> observers = new ArrayList<>();
+ this.observers = Collections.unmodifiableList(observers);
+
+ // We need to ensure that no sstable components exist before the
lifecycle transaction starts tracking it.
+ // Otherwise, it means that we either want to overwrite some existing
sstable, which is not allowed, or some
+ // sstable files were created before the sstable is registered in the
lifecycle transaction, which may lead
+ // to a race such that the sstable is listed as completed due to the
lack of the transaction file before
+ // anything is actually written to it.
+ Set<Component> existingComponents = Sets.filter(components, c ->
descriptor.fileFor(c).exists());
+
+ assert existingComponents.isEmpty() : String.format("Cannot create a
new SSTable in directory %s as a files for components %s already exist there",
Review Comment:
nit: `Cannot create a new SSTable in directory %s as component files %s
already exist there` would read better.
--
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]