mirror of https://github.com/apache/cassandra
Fsync TOC and Digest files after they're written
Patch by Maciej Sokol; reviewed by brandonwilliams and bereng for CASSANDRA-10709
This commit is contained in:
parent
0bcc354992
commit
5d427ff6e5
|
|
@ -1,4 +1,5 @@
|
|||
3.0.27
|
||||
* fsync TOC and digest files (CASSANDRA-10709)
|
||||
* Fix URISyntaxException in nodetool with updated Java (CASSANDRA-17581)
|
||||
* Schema mutations may not be completed on drain (CASSANDRA-17524)
|
||||
* Fix data corruption in AbstractCompositeType due to static boolean byte buffers (CASSANDRA-14752)
|
||||
|
|
|
|||
|
|
@ -299,10 +299,13 @@ public abstract class SSTable
|
|||
protected static void appendTOC(Descriptor descriptor, Collection<Component> components)
|
||||
{
|
||||
File tocFile = new File(descriptor.filenameFor(Component.TOC));
|
||||
try (PrintWriter w = new PrintWriter(new FileWriter(tocFile, true)))
|
||||
try (FileOutputStream fos = new FileOutputStream(tocFile);
|
||||
PrintWriter w = new PrintWriter(fos))
|
||||
{
|
||||
for (Component component : components)
|
||||
w.println(component.name);
|
||||
w.flush();
|
||||
fos.getFD().sync();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -17,20 +17,20 @@
|
|||
*/
|
||||
package org.apache.cassandra.io.util;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.Closeable;
|
||||
import java.io.DataOutput;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOError;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.zip.CRC32;
|
||||
import java.util.zip.CheckedInputStream;
|
||||
import java.util.zip.Checksum;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
|
||||
import org.apache.cassandra.io.FSWriteError;
|
||||
import org.apache.cassandra.io.sstable.Component;
|
||||
import org.apache.cassandra.io.sstable.Descriptor;
|
||||
|
|
@ -209,9 +209,12 @@ public class DataIntegrityMetadata
|
|||
if (descriptor.digestComponent == null)
|
||||
throw new NullPointerException("Null digest component for " + descriptor.ksname + '.' + descriptor.cfname + " file " + descriptor.baseFilename());
|
||||
File outFile = new File(descriptor.filenameFor(descriptor.digestComponent));
|
||||
try (BufferedWriter out =Files.newBufferedWriter(outFile.toPath(), Charsets.UTF_8))
|
||||
try (FileOutputStream fos = new FileOutputStream(outFile);
|
||||
DataOutputStream out = new DataOutputStream(new BufferedOutputStream(fos)))
|
||||
{
|
||||
out.write(String.valueOf(fullChecksum.getValue()));
|
||||
out.write(String.valueOf(fullChecksum.getValue()).getBytes(StandardCharsets.UTF_8));
|
||||
out.flush();
|
||||
fos.getFD().sync();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue