cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From marc...@apache.org
Subject [3/5] git commit: fsync leveled manifest to avoid it getting corrupt
Date Sat, 04 May 2013 18:43:27 GMT
fsync leveled manifest to avoid it getting corrupt

Patch by marcuse, reviewed by jbellis and carlyeks for CASSANDRA-5535


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/fe910e6c
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/fe910e6c
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/fe910e6c

Branch: refs/heads/trunk
Commit: fe910e6c90d81cc61c16859bcef9f0dcb42cc827
Parents: b4b4f6a
Author: Marcus Eriksson <marcuse@spotify.com>
Authored: Sat May 4 18:49:04 2013 +0200
Committer: Marcus Eriksson <marcuse@spotify.com>
Committed: Sat May 4 20:28:03 2013 +0200

----------------------------------------------------------------------
 CHANGES.txt                                        |    2 +-
 .../cassandra/db/compaction/LeveledManifest.java   |    6 +++++-
 2 files changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/fe910e6c/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 30a09c9..5a559a8 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -2,7 +2,7 @@
  * Add retry mechanism to OTC for non-droppable_verbs (CASSANDRA-5393)
  * Use allocator information to improve memtable memory usage estimate 
    (CASSANDRA-5497)
-
+ * fsync leveled manifest to avoid corruption (CASSANDRA-5535)
 
 1.1.11
  * Fix trying to load deleted row into row cache on startup (CASSANDRA-4463)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/fe910e6c/src/java/org/apache/cassandra/db/compaction/LeveledManifest.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/compaction/LeveledManifest.java b/src/java/org/apache/cassandra/db/compaction/LeveledManifest.java
index 5f22109..8ac7028 100644
--- a/src/java/org/apache/cassandra/db/compaction/LeveledManifest.java
+++ b/src/java/org/apache/cassandra/db/compaction/LeveledManifest.java
@@ -22,6 +22,7 @@ package org.apache.cassandra.db.compaction;
 
 
 import java.io.File;
+import java.io.FileOutputStream;
 import java.io.IOError;
 import java.io.IOException;
 import java.util.*;
@@ -534,7 +535,8 @@ public class LeveledManifest
         JsonFactory f = new JsonFactory();
         try
         {
-            JsonGenerator g = f.createJsonGenerator(tmpFile, JsonEncoding.UTF8);
+            FileOutputStream fos = new FileOutputStream(tmpFile);
+            JsonGenerator g = f.createJsonGenerator(fos, JsonEncoding.UTF8);
             g.useDefaultPrettyPrinter();
             g.writeStartObject();
             g.writeArrayFieldStart("generations");
@@ -551,6 +553,8 @@ public class LeveledManifest
             }
             g.writeEndArray(); // for field generations
             g.writeEndObject(); // write global object
+            g.flush();
+            fos.getFD().sync();
             g.close();
 
             if (oldFile.exists() && manifestFile.exists())


Mime
View raw message