You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ch...@apache.org on 2013/10/09 15:15:56 UTC
[2/2] git commit: Fixes leveldb replication bug that can cause read
errors: make sure that log is flushed for records that are being read.
Fixes leveldb replication bug that can cause read errors: make sure that log is flushed for records that are being read.
Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/119fdab1
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/119fdab1
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/119fdab1
Branch: refs/heads/trunk
Commit: 119fdab1d005064ad81c023674522e8175cb975c
Parents: b1bf994
Author: Hiram Chirino <hi...@hiramchirino.com>
Authored: Tue Oct 8 18:37:06 2013 -0400
Committer: Hiram Chirino <hi...@hiramchirino.com>
Committed: Wed Oct 9 09:15:48 2013 -0400
----------------------------------------------------------------------
.../src/main/scala/org/apache/activemq/leveldb/RecordLog.scala | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq/blob/119fdab1/activemq-leveldb-store/src/main/scala/org/apache/activemq/leveldb/RecordLog.scala
----------------------------------------------------------------------
diff --git a/activemq-leveldb-store/src/main/scala/org/apache/activemq/leveldb/RecordLog.scala b/activemq-leveldb-store/src/main/scala/org/apache/activemq/leveldb/RecordLog.scala
index 5a4629e..abf967b 100644
--- a/activemq-leveldb-store/src/main/scala/org/apache/activemq/leveldb/RecordLog.scala
+++ b/activemq-leveldb-store/src/main/scala/org/apache/activemq/leveldb/RecordLog.scala
@@ -306,18 +306,20 @@ case class RecordLog(directory: File, logSuffix:String) {
def read(record_position:Long) = {
val offset = record_position-position
val header = new Buffer(LOG_HEADER_SIZE)
+ check_read_flush(offset+LOG_HEADER_SIZE)
channel.read(header.toByteBuffer, offset)
val is = header.bigEndianEditor();
val prefix = is.readByte()
if( prefix != LOG_HEADER_PREFIX ) {
// Does not look like a record.
- throw new IOException("invalid record position")
+ throw new IOException("invalid record position %d (file: %s, offset: %d)".format(record_position, file.getName, offset))
}
val id = is.readByte()
val expectedChecksum = is.readInt()
val length = is.readInt()
val data = new Buffer(length)
+ check_read_flush(offset+LOG_HEADER_SIZE+length)
if( channel.read(data.toByteBuffer, offset+LOG_HEADER_SIZE) != length ) {
throw new IOException("short record")
}