Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import org.apache.cassandra.schema.TableId;
import org.apache.cassandra.schema.TableMetadata;
import org.apache.cassandra.utils.IntegerInterval;
import org.apache.cassandra.utils.SyncUtil;
import org.apache.cassandra.utils.concurrent.OpOrder;
import org.apache.cassandra.utils.concurrent.WaitQueue;

Expand Down Expand Up @@ -167,6 +168,7 @@ static long getNextId()
throw new FSWriteError(e, logFile);
}

SyncUtil.trySyncDir(logFile.parent());
this.buffer = createBuffer();
}

Expand Down
1 change: 1 addition & 0 deletions src/java/org/apache/cassandra/hints/HintsWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ static HintsWriter create(File directory, HintsDescriptor descriptor) throws IOE
File file = descriptor.file(directory);

FileChannel channel = FileChannel.open(file.toPath(), StandardOpenOption.WRITE, StandardOpenOption.CREATE_NEW);
SyncUtil.trySyncDir(directory);
int fd = NativeLibrary.getfd(channel);

CRC32 crc = new CRC32();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@
import org.apache.cassandra.io.util.DataInputBuffer;
import org.apache.cassandra.io.util.DataOutputBuffer;
import org.apache.cassandra.io.util.DataOutputPlus;
import org.apache.cassandra.io.util.DataOutputStreamPlus;
import org.apache.cassandra.io.util.File;
import org.apache.cassandra.io.util.FileDataInput;
import org.apache.cassandra.io.util.FileOutputStreamPlus;
import org.apache.cassandra.io.util.RandomAccessReader;
import org.apache.cassandra.utils.SyncUtil;
import org.apache.cassandra.utils.TimeUUID;

import static org.apache.cassandra.utils.FBUtilities.updateChecksumInt;
Expand Down Expand Up @@ -267,16 +268,18 @@ private void mutate(Descriptor descriptor, UnaryOperator<StatsMetadata> transfor
public void rewriteSSTableMetadata(Descriptor descriptor, Map<MetadataType, MetadataComponent> currentComponents) throws IOException
{
File file = descriptor.tmpFileFor(Components.STATS);
try (DataOutputStreamPlus out = file.newOutputStream(File.WriteMode.OVERWRITE))
try (FileOutputStreamPlus out = file.newOutputStream(File.WriteMode.OVERWRITE))
{
serialize(currentComponents, out, descriptor.version);
out.flush();
out.sync();
}
catch (IOException e)
{
Throwables.throwIfInstanceOf(e, FileNotFoundException.class);
throw new FSWriteError(e, file);
}
file.move(descriptor.fileFor(Components.STATS));
SyncUtil.trySyncDir(descriptor.directory);
}
}
2 changes: 2 additions & 0 deletions src/java/org/apache/cassandra/io/util/FileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,8 @@ public static void write(File file, List<String> lines, StandardOpenOption ... o
writer.newLine();
}

writer.flush();

if (sync)
{
SyncUtil.force(fc, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.apache.cassandra.service.accord.AccordService;
import org.apache.cassandra.service.paxos.Ballot;
import org.apache.cassandra.service.paxos.Commit;
import org.apache.cassandra.utils.SyncUtil;

import static org.apache.cassandra.io.util.SequentialWriterOption.FINISH_ON_CLOSE;
import static org.apache.cassandra.utils.Crc.crc32;
Expand Down Expand Up @@ -136,6 +137,7 @@ public synchronized void flush() throws IOException
writer.writeInt(Integer.reverseBytes((int) crc.getValue()));
}
file.move(new File(directory, FNAME));
SyncUtil.trySyncDir(directory);
}

public synchronized void truncate()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import org.apache.cassandra.utils.AbstractIterator;
import org.apache.cassandra.utils.ByteBufferUtil;
import org.apache.cassandra.utils.CloseableIterator;
import org.apache.cassandra.utils.SyncUtil;
import org.apache.cassandra.utils.Throwables;

public class UncommittedDataFile
Expand Down Expand Up @@ -252,6 +253,7 @@ UncommittedDataFile finish()
{
crcFile.move(finalCrc);
file.move(finalData);
SyncUtil.trySyncDir(directory);
return new UncommittedDataFile(tableId, finalData, finalCrc, generation);
}
catch (Throwable e)
Expand Down