mirror of https://github.com/apache/cassandra
[fixed version] avoid opening multiple writers for the current file; the buffered nature of the global logWriter_ could cause problems
patch by jbellis; reviewed for CASSANDRA-370 by Sammy Yu git-svn-id: https://svn.apache.org/repos/asf/incubator/cassandra/trunk@807399 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
eb49a18acd
commit
a2899de137
|
|
@ -246,16 +246,6 @@ public class CommitLog
|
|||
return CommitLogHeader.serializer().deserialize(new DataInputStream(byteStream));
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the serialized commit log header into the specified commit log.
|
||||
*/
|
||||
private static void writeCommitLogHeader(String commitLogFileName, byte[] bytes) throws IOException
|
||||
{
|
||||
RandomAccessFile logWriter = CommitLog.createWriter(commitLogFileName);
|
||||
writeCommitLogHeader(logWriter, bytes);
|
||||
logWriter.close();
|
||||
}
|
||||
|
||||
/*
|
||||
* This is invoked on startup via the ctor. It basically
|
||||
* writes a header with all bits set to zero.
|
||||
|
|
@ -509,7 +499,7 @@ public class CommitLog
|
|||
* perform & operation and then turn on with the new position.
|
||||
*/
|
||||
commitLogHeader.turnOn(id, cLogCtx.position);
|
||||
writeCommitLogHeader(cLogCtx.file, commitLogHeader.toByteArray());
|
||||
seekAndWriteCommitLogHeader(commitLogHeader.toByteArray());
|
||||
break;
|
||||
}
|
||||
else
|
||||
|
|
@ -525,7 +515,9 @@ public class CommitLog
|
|||
}
|
||||
else
|
||||
{
|
||||
writeCommitLogHeader(oldFile, oldCommitLogHeader.toByteArray());
|
||||
RandomAccessFile logWriter = CommitLog.createWriter(oldFile);
|
||||
writeCommitLogHeader(logWriter, oldCommitLogHeader.toByteArray());
|
||||
logWriter.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue