[Groonga-commit] pgroonga/pgroonga at e2ba1da [master] wal: support resume on error

Back to archive index

Kouhei Sutou null+****@clear*****
Sat Oct 29 16:39:41 JST 2016


Kouhei Sutou	2016-10-29 16:39:41 +0900 (Sat, 29 Oct 2016)

  New Revision: e2ba1da06b4d9e994b2a7a6f86a5ddaf0739da91
  https://github.com/pgroonga/pgroonga/commit/e2ba1da06b4d9e994b2a7a6f86a5ddaf0739da91

  Message:
    wal: support resume on error

  Modified files:
    src/pgrn_wal.c

  Modified: src/pgrn_wal.c (+12 -12)
===================================================================
--- src/pgrn_wal.c    2016-10-29 16:05:02 +0900 (7f3f2b5)
+++ src/pgrn_wal.c    2016-10-29 16:39:41 +0900 (df35368)
@@ -1317,25 +1317,27 @@ PGrnWALApplyObject(PGrnWALApplyData *data, msgpack_object *object)
 static void
 PGrnWALApplyConsume(PGrnWALApplyData *data)
 {
-	BlockNumber i, nBlocks;
+	BlockNumber i;
+	BlockNumber startBlock;
+	BlockNumber nBlocks;
 	msgpack_unpacker unpacker;
 	msgpack_unpacked unpacked;
-	BlockNumber lastBlock = data->current.block;
-	OffsetNumber lastOffset = data->current.offset;
+	size_t unpackerBaseOffset;
 
 	msgpack_unpacker_init(&unpacker, PGRN_PAGE_DATA_SIZE);
+	unpackerBaseOffset = unpacker.off;
 	msgpack_unpacked_init(&unpacked);
+	startBlock = data->current.block;
+	if (startBlock == PGRN_WAL_META_PAGE_BLOCK_NUMBER)
+		startBlock++;
 	nBlocks = RelationGetNumberOfBlocks(data->index);
-	for (i = data->current.block; i < nBlocks; i++)
+	for (i = startBlock; i < nBlocks; i++)
 	{
 		Buffer buffer;
 		Page page;
 		PGrnWALPageSpecial *pageSpecial;
 		size_t dataSize;
 
-		if (i == PGRN_WAL_META_PAGE_BLOCK_NUMBER)
-			continue;
-
 		buffer = ReadBuffer(data->index, i);
 		LockBuffer(buffer, BUFFER_LOCK_SHARE);
 		page = BufferGetPage(buffer);
@@ -1353,15 +1355,13 @@ PGrnWALApplyConsume(PGrnWALApplyData *data)
 			   MSGPACK_UNPACK_SUCCESS)
 		{
 			PGrnWALApplyObject(data, &unpacked.data);
+			PGrnWALUpdateStatus(data->index,
+								i,
+								unpacker.off - unpackerBaseOffset);
 		}
-
-		lastBlock = i;
-		lastOffset = pageSpecial->current;
 	}
 	msgpack_unpacked_destroy(&unpacked);
 	msgpack_unpacker_destroy(&unpacker);
-
-	PGrnWALUpdateStatus(data->index, lastBlock, lastOffset);
 }
 #endif
 
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index