@@ -130,7 +130,6 @@ btree_xlog_insert(bool isleaf, bool ismeta,
130130{
131131 xl_btree_insert * xlrec = (xl_btree_insert * ) XLogRecGetData (record );
132132 Buffer buffer ;
133- Buffer cbuffer = InvalidBuffer ;
134133 Page page ;
135134 char * datapos ;
136135 int datalen ;
@@ -158,6 +157,15 @@ btree_xlog_insert(bool isleaf, bool ismeta,
158157 datalen -= sizeof (xl_btree_metadata );
159158 }
160159
160+ /*
161+ * Insertion to an internal page finishes an incomplete split at the
162+ * child level. Clear the incomplete-split flag in the child. Note:
163+ * during normal operation, the child and parent pages are locked at the
164+ * same time, so that clearing the flag and inserting the downlink appear
165+ * atomic to other backends. We don't bother with that during replay,
166+ * because readers don't care about the incomplete-split flag and there
167+ * cannot be updates happening.
168+ */
161169 if (!isleaf )
162170 {
163171 if (record -> xl_info & XLR_BKP_BLOCK (0 ))
@@ -194,9 +202,6 @@ btree_xlog_insert(bool isleaf, bool ismeta,
194202 }
195203 }
196204
197- if (BufferIsValid (cbuffer ))
198- UnlockReleaseBuffer (cbuffer );
199-
200205 /*
201206 * Note: in normal operation, we'd update the metapage while still holding
202207 * lock on the page we inserted into. But during replay it's not
@@ -273,7 +278,8 @@ btree_xlog_split(bool onleft, bool isroot,
273278
274279 /*
275280 * Clear the incomplete split flag on the left sibling of the child page
276- * this is a downlink for.
281+ * this is a downlink for. (Like in btree_xlog_insert, this can be done
282+ * before locking the other pages)
277283 */
278284 if (!isleaf )
279285 {
0 commit comments