1/*-
2 * See the file LICENSE for redistribution information.
3 *
4 * Copyright (c) 1999,2008 Oracle.  All rights reserved.
5 *
6 * $Id: qam_rec.c,v 12.32 2008/03/13 15:44:50 mbrey Exp $
7 */
8
9#include "db_config.h"
10
11#include "db_int.h"
12#include "dbinc/db_page.h"
13#include "dbinc/db_am.h"
14#include "dbinc/lock.h"
15#include "dbinc/log.h"
16#include "dbinc/mp.h"
17#include "dbinc/qam.h"
18#include "dbinc/txn.h"
19
20/*
21 * LSNs in queue data pages are advisory.  They do not have to be accurate
22 * as all operations are idempotent on records.  They should not be rolled
23 * forward during recovery as committed transaction may obscure updates from
24 * an incomplete transaction that updates the same page.  The incomplete
25 * transaction may be completed during a later hot backup cycle.
26 */
27
28/* Queue version of REC_DIRTY -- needs to probe the correct file. */
29#define	QAM_DIRTY(dbc, pgno, pagep)					\
30	if ((ret = __qam_dirty((dbc),					\
31	    pgno, pagep, (dbc)->priority)) != 0) {			\
32		ret = __db_pgerr((dbc)->dbp, (pgno), ret);		\
33		goto out;						\
34	}
35
36/*
37 * __qam_incfirst_recover --
38 *	Recovery function for incfirst.
39 *
40 * PUBLIC: int __qam_incfirst_recover
41 * PUBLIC:   __P((ENV *, DBT *, DB_LSN *, db_recops, void *));
42 */
43int
44__qam_incfirst_recover(env, dbtp, lsnp, op, info)
45	ENV *env;
46	DBT *dbtp;
47	DB_LSN *lsnp;
48	db_recops op;
49	void *info;
50{
51	__qam_incfirst_args *argp;
52	DB_THREAD_INFO *ip;
53	DB *file_dbp;
54	DBC *dbc;
55	DB_LOCK lock;
56	DB_LSN trunc_lsn;
57	DB_MPOOLFILE *mpf;
58	QMETA *meta;
59	QUEUE_CURSOR *cp;
60	db_pgno_t metapg;
61	u_int32_t rec_ext;
62	int exact, ret, t_ret;
63
64	COMPQUIET(meta, NULL);
65
66	ip = ((DB_TXNHEAD *)info)->thread_info;
67	LOCK_INIT(lock);
68	REC_PRINT(__qam_incfirst_print);
69	REC_INTRO(__qam_incfirst_read, ip, 1);
70
71	metapg = ((QUEUE *)file_dbp->q_internal)->q_meta;
72
73	if ((ret = __db_lget(dbc,
74	    LCK_ROLLBACK, metapg,  DB_LOCK_WRITE, 0, &lock)) != 0)
75		goto done;
76	if ((ret = __memp_fget(mpf, &metapg, ip, NULL,
77	    0, &meta)) != 0) {
78		if (DB_REDO(op)) {
79			if ((ret = __memp_fget(mpf, &metapg, ip, NULL,
80			    DB_MPOOL_CREATE, &meta)) != 0) {
81				(void)__LPUT(dbc, lock);
82				goto out;
83			}
84			meta->dbmeta.pgno = metapg;
85			meta->dbmeta.type = P_QAMMETA;
86		} else {
87			*lsnp = argp->prev_lsn;
88			ret = __LPUT(dbc, lock);
89			goto out;
90		}
91	}
92
93	/*
94	 * Only move first_recno backwards so we pick up the aborted delete.
95	 * When going forward we need to be careful since
96	 * we may have bumped over a locked record.
97	 */
98	if (DB_UNDO(op)) {
99		if (QAM_BEFORE_FIRST(meta, argp->recno)) {
100			REC_DIRTY(mpf, ip, dbc->priority, &meta);
101			meta->first_recno = argp->recno;
102		}
103
104		trunc_lsn = ((DB_TXNHEAD *)info)->trunc_lsn;
105		/* if we are truncating, update the LSN */
106		if (!IS_ZERO_LSN(trunc_lsn) &&
107		    LOG_COMPARE(&LSN(meta), &trunc_lsn) > 0) {
108			REC_DIRTY(mpf, ip, dbc->priority, &meta);
109			LSN(meta) = trunc_lsn;
110		}
111	} else {
112		if (LOG_COMPARE(&LSN(meta), lsnp) < 0) {
113			REC_DIRTY(mpf, ip, dbc->priority, &meta);
114			LSN(meta) = *lsnp;
115		}
116		if (meta->page_ext == 0)
117			rec_ext = 0;
118		else
119			rec_ext = meta->page_ext * meta->rec_page;
120		cp = (QUEUE_CURSOR *)dbc->internal;
121		if (meta->first_recno == RECNO_OOB)
122			meta->first_recno++;
123		while (meta->first_recno != meta->cur_recno &&
124		    !QAM_BEFORE_FIRST(meta, argp->recno + 1)) {
125			if ((ret = __qam_position(dbc,
126			    &meta->first_recno, DB_LOCK_READ, 0, &exact)) != 0)
127				goto err;
128			if (cp->page != NULL && (ret = __qam_fput(dbc,
129			    cp->pgno, cp->page, dbc->priority)) != 0)
130				goto err;
131
132			if (exact == 1)
133				break;
134			if (cp->page != NULL &&
135			    rec_ext != 0 && meta->first_recno % rec_ext == 0)
136				if ((ret =
137				    __qam_fremove(file_dbp, cp->pgno)) != 0)
138					goto err;
139			REC_DIRTY(mpf, ip, dbc->priority, &meta);
140			meta->first_recno++;
141			if (meta->first_recno == RECNO_OOB)
142				meta->first_recno++;
143		}
144	}
145
146	ret = __memp_fput(mpf, ip, meta, dbc->priority);
147	if ((t_ret = __LPUT(dbc, lock)) != 0 && ret == 0)
148		ret = t_ret;
149	if (ret != 0)
150		goto out;
151
152done:	*lsnp = argp->prev_lsn;
153	ret = 0;
154
155	if (0) {
156err:		(void)__memp_fput(mpf, ip, meta, dbc->priority);
157		(void)__LPUT(dbc, lock);
158	}
159
160out:	REC_CLOSE;
161}
162
163/*
164 * __qam_mvptr_recover --
165 *	Recovery function for mvptr.
166 *
167 * PUBLIC: int __qam_mvptr_recover
168 * PUBLIC:    __P((ENV *, DBT *, DB_LSN *, db_recops, void *));
169 */
170int
171__qam_mvptr_recover(env, dbtp, lsnp, op, info)
172	ENV *env;
173	DBT *dbtp;
174	DB_LSN *lsnp;
175	db_recops op;
176	void *info;
177{
178	__qam_mvptr_args *argp;
179	DB_THREAD_INFO *ip;
180	DB *file_dbp;
181	DBC *dbc;
182	DB_LSN trunc_lsn;
183	DB_LOCK lock;
184	DB_MPOOLFILE *mpf;
185	QMETA *meta;
186	QUEUE_CURSOR *cp;
187	db_pgno_t metapg;
188	int cmp_n, cmp_p, exact, ret;
189
190	ip = ((DB_TXNHEAD *)info)->thread_info;
191	REC_PRINT(__qam_mvptr_print);
192	REC_INTRO(__qam_mvptr_read, ip, 1);
193
194	metapg = ((QUEUE *)file_dbp->q_internal)->q_meta;
195
196	if ((ret = __db_lget(dbc,
197	    LCK_ROLLBACK, metapg,  DB_LOCK_WRITE, 0, &lock)) != 0)
198		goto done;
199	if ((ret = __memp_fget(mpf, &metapg, ip, NULL, 0, &meta)) != 0) {
200		if (DB_REDO(op)) {
201			if ((ret = __memp_fget(mpf, &metapg, ip, NULL,
202			    DB_MPOOL_CREATE, &meta)) != 0) {
203				(void)__LPUT(dbc, lock);
204				goto out;
205			}
206			meta->dbmeta.pgno = metapg;
207			meta->dbmeta.type = P_QAMMETA;
208		} else {
209			*lsnp = argp->prev_lsn;
210			ret = __LPUT(dbc, lock);
211			goto out;
212		}
213	}
214
215	cmp_n = LOG_COMPARE(lsnp, &LSN(meta));
216	cmp_p = LOG_COMPARE(&LSN(meta), &argp->metalsn);
217
218	/*
219	 * Under normal circumstances, we never undo a movement of one of
220	 * the pointers.  Just move them along regardless of abort/commit.
221	 * When going forward we need to verify that this is really where
222	 * the pointer belongs.  A transaction may roll back and reinsert
223	 * a record that was missing at the time of this action.
224	 *
225	 * If we're undoing a truncate, we need to reset the pointers to
226	 * their state before the truncate.
227	 */
228	if (DB_UNDO(op)) {
229		if ((argp->opcode & QAM_TRUNCATE) && cmp_n <= 0) {
230			REC_DIRTY(mpf, ip, dbc->priority, &meta);
231			meta->first_recno = argp->old_first;
232			meta->cur_recno = argp->old_cur;
233			LSN(meta) = argp->metalsn;
234		}
235		/* If the page lsn is beyond the truncate point, move it back */
236		trunc_lsn = ((DB_TXNHEAD *)info)->trunc_lsn;
237		if (!IS_ZERO_LSN(trunc_lsn) &&
238		    LOG_COMPARE(&trunc_lsn, &LSN(meta)) < 0) {
239			REC_DIRTY(mpf, ip, dbc->priority, &meta);
240			LSN(meta) = argp->metalsn;
241		}
242	} else if (op == DB_TXN_APPLY || cmp_p == 0) {
243		REC_DIRTY(mpf, ip, dbc->priority, &meta);
244		cp = (QUEUE_CURSOR *)dbc->internal;
245		if ((argp->opcode & QAM_SETFIRST) &&
246		    meta->first_recno == argp->old_first) {
247			if (argp->old_first > argp->new_first)
248				meta->first_recno = argp->new_first;
249			else {
250				if ((ret = __qam_position(dbc,
251				    &meta->first_recno, DB_LOCK_READ, 0,
252				    &exact)) != 0)
253					goto err;
254				if (!exact)
255					meta->first_recno = argp->new_first;
256				if (cp->page != NULL &&
257				    (ret = __qam_fput(dbc,
258				    cp->pgno, cp->page, dbc->priority)) != 0)
259					goto err;
260			}
261		}
262
263		if ((argp->opcode & QAM_SETCUR) &&
264		    meta->cur_recno == argp->old_cur) {
265			if (argp->old_cur < argp->new_cur)
266				meta->cur_recno = argp->new_cur;
267			else {
268				if ((ret = __qam_position(dbc, &meta->cur_recno,
269				    DB_LOCK_READ, 0, &exact)) != 0)
270					goto err;
271				if (!exact)
272					meta->cur_recno = argp->new_cur;
273				if (cp->page != NULL &&
274				    (ret = __qam_fput(dbc,
275				    cp->pgno, cp->page, dbc->priority)) != 0)
276					goto err;
277			}
278		}
279
280		meta->dbmeta.lsn = *lsnp;
281	}
282
283	if ((ret = __memp_fput(mpf, ip, meta, dbc->priority)) != 0)
284		goto out;
285
286	if ((ret = __LPUT(dbc, lock)) != 0)
287		goto out;
288
289done:	*lsnp = argp->prev_lsn;
290	ret = 0;
291
292	if (0) {
293err:		(void)__memp_fput(mpf, ip, meta, dbc->priority);
294		(void)__LPUT(dbc, lock);
295	}
296
297out:	REC_CLOSE;
298}
299
300/*
301 * __qam_del_recover --
302 *	Recovery function for del.
303 *		Non-extent version or if there is no data (zero len).
304 *
305 * PUBLIC: int __qam_del_recover
306 * PUBLIC:      __P((ENV *, DBT *, DB_LSN *, db_recops, void *));
307 */
308int
309__qam_del_recover(env, dbtp, lsnp, op, info)
310	ENV *env;
311	DBT *dbtp;
312	DB_LSN *lsnp;
313	db_recops op;
314	void *info;
315{
316	__qam_del_args *argp;
317	DB_THREAD_INFO *ip;
318	DB *file_dbp;
319	DBC *dbc;
320	DB_LOCK lock;
321	DB_MPOOLFILE *mpf;
322	QAMDATA *qp;
323	QMETA *meta;
324	QPAGE *pagep;
325	db_pgno_t metapg;
326	int cmp_n, ret, t_ret;
327
328	COMPQUIET(pagep, NULL);
329
330	ip = ((DB_TXNHEAD *)info)->thread_info;
331	REC_PRINT(__qam_del_print);
332	REC_INTRO(__qam_del_read, ip, 1);
333
334	if ((ret = __qam_fget(dbc, &argp->pgno, DB_MPOOL_CREATE, &pagep)) != 0)
335		goto out;
336
337	if (pagep->pgno == PGNO_INVALID) {
338		QAM_DIRTY(dbc, argp->pgno, &pagep);
339		pagep->pgno = argp->pgno;
340		pagep->type = P_QAMDATA;
341	}
342
343	cmp_n = LOG_COMPARE(lsnp, &LSN(pagep));
344
345	if (DB_UNDO(op)) {
346		/* make sure first is behind us */
347		metapg = ((QUEUE *)file_dbp->q_internal)->q_meta;
348		if ((ret = __db_lget(dbc,
349		    LCK_ROLLBACK, metapg, DB_LOCK_WRITE, 0, &lock)) != 0)
350			goto err;
351		if ((ret = __memp_fget(mpf, &metapg, ip, NULL,
352		    DB_MPOOL_EDIT, &meta)) != 0) {
353			(void)__LPUT(dbc, lock);
354			goto err;
355		}
356		if (meta->first_recno == RECNO_OOB ||
357		    (QAM_BEFORE_FIRST(meta, argp->recno) &&
358		    (meta->first_recno <= meta->cur_recno ||
359		    meta->first_recno -
360		    argp->recno < argp->recno - meta->cur_recno))) {
361			REC_DIRTY(mpf, ip, dbc->priority, &meta);
362			meta->first_recno = argp->recno;
363			ret = __memp_fput(mpf, ip, meta, dbc->priority);
364		} else
365			ret = __memp_fput(mpf, ip, meta, dbc->priority);
366		if ((t_ret = __LPUT(dbc, lock)) != 0 && ret == 0)
367			ret = t_ret;
368		if (ret != 0)
369			goto err;
370
371		/* Need to undo delete - mark the record as present */
372		QAM_DIRTY(dbc, pagep->pgno, &pagep);
373		qp = QAM_GET_RECORD(file_dbp, pagep, argp->indx);
374		F_SET(qp, QAM_VALID);
375
376		/*
377		 * Move the LSN back to this point;  do not move it forward.
378		 * If we're in an abort, because we don't hold a page lock,
379		 * we could foul up a concurrent put.  Having too late an
380		 * LSN * is harmless in queue except when we're determining
381		 * what we need to roll forward during recovery.  [#2588]
382		 */
383		if (cmp_n <= 0 && op == DB_TXN_BACKWARD_ROLL)
384			LSN(pagep) = argp->lsn;
385	} else if (op == DB_TXN_APPLY || (cmp_n > 0 && DB_REDO(op))) {
386		/* Need to redo delete - clear the valid bit */
387		QAM_DIRTY(dbc, pagep->pgno, &pagep);
388		qp = QAM_GET_RECORD(file_dbp, pagep, argp->indx);
389		F_CLR(qp, QAM_VALID);
390		/*
391		 * We only move the LSN forward during replication.
392		 * During recovery we could obscure an update from
393		 * a partially completed transaction while processing
394		 * a hot backup.  [#13823]
395		 */
396		if (op == DB_TXN_APPLY)
397			LSN(pagep) = *lsnp;
398	}
399	if ((ret = __qam_fput(dbc, argp->pgno, pagep, dbc->priority)) != 0)
400		goto out;
401
402done:	*lsnp = argp->prev_lsn;
403	ret = 0;
404
405	if (0) {
406err:		(void)__qam_fput(dbc, argp->pgno, pagep, dbc->priority);
407	}
408out:	REC_CLOSE;
409}
410
411/*
412 * __qam_delext_recover --
413 *	Recovery function for del in an extent based queue.
414 *
415 * PUBLIC: int __qam_delext_recover
416 * PUBLIC:      __P((ENV *, DBT *, DB_LSN *, db_recops, void *));
417 */
418int
419__qam_delext_recover(env, dbtp, lsnp, op, info)
420	ENV *env;
421	DBT *dbtp;
422	DB_LSN *lsnp;
423	db_recops op;
424	void *info;
425{
426	__qam_delext_args *argp;
427	DB_THREAD_INFO *ip;
428	DB *file_dbp;
429	DBC *dbc;
430	DB_LOCK lock;
431	DB_MPOOLFILE *mpf;
432	QAMDATA *qp;
433	QMETA *meta;
434	QPAGE *pagep;
435	db_pgno_t metapg;
436	int cmp_n, ret, t_ret;
437
438	COMPQUIET(pagep, NULL);
439
440	ip = ((DB_TXNHEAD *)info)->thread_info;
441	REC_PRINT(__qam_delext_print);
442	REC_INTRO(__qam_delext_read, ip, 1);
443
444	if ((ret = __qam_fget(dbc, &argp->pgno,
445	     DB_REDO(op) ? 0 : DB_MPOOL_CREATE, &pagep)) != 0) {
446		/*
447		 * If we are redoing a delete and the page is not there
448		 * we are done.
449		 */
450		if (DB_REDO(op) && (ret == DB_PAGE_NOTFOUND || ret == ENOENT))
451			goto done;
452		goto out;
453	}
454
455	if (pagep->pgno == PGNO_INVALID) {
456		QAM_DIRTY(dbc, argp->pgno, &pagep);
457		pagep->pgno = argp->pgno;
458		pagep->type = P_QAMDATA;
459	}
460
461	cmp_n = LOG_COMPARE(lsnp, &LSN(pagep));
462
463	if (DB_UNDO(op)) {
464		/* make sure first is behind us */
465		metapg = ((QUEUE *)file_dbp->q_internal)->q_meta;
466		if ((ret = __db_lget(dbc,
467		    LCK_ROLLBACK, metapg, DB_LOCK_WRITE, 0, &lock)) != 0)
468			goto err;
469		if ((ret = __memp_fget(mpf, &metapg, ip, NULL,
470		    DB_MPOOL_EDIT, &meta)) != 0) {
471			(void)__LPUT(dbc, lock);
472			goto err;
473		}
474		if (meta->first_recno == RECNO_OOB ||
475		    (QAM_BEFORE_FIRST(meta, argp->recno) &&
476		    (meta->first_recno <= meta->cur_recno ||
477		    meta->first_recno -
478		    argp->recno < argp->recno - meta->cur_recno))) {
479			meta->first_recno = argp->recno;
480			ret = __memp_fput(mpf, ip, meta, dbc->priority);
481		} else
482			ret = __memp_fput(mpf, ip, meta, dbc->priority);
483		if ((t_ret = __LPUT(dbc, lock)) != 0 && ret == 0)
484			ret = t_ret;
485		if (ret != 0)
486			goto err;
487
488		QAM_DIRTY(dbc, pagep->pgno, &pagep);
489		if ((ret = __qam_pitem(dbc, pagep,
490		    argp->indx, argp->recno, &argp->data)) != 0)
491			goto err;
492
493		/*
494		 * Move the LSN back to this point;  do not move it forward.
495		 * If we're in an abort, because we don't hold a page lock,
496		 * we could foul up a concurrent put.  Having too late an
497		 * LSN is harmless in queue except when we're determining
498		 * what we need to roll forward during recovery.  [#2588]
499		 */
500		if (cmp_n <= 0 && op == DB_TXN_BACKWARD_ROLL)
501			LSN(pagep) = argp->lsn;
502	} else if (op == DB_TXN_APPLY || (cmp_n > 0 && DB_REDO(op))) {
503		QAM_DIRTY(dbc, pagep->pgno, &pagep);
504		/* Need to redo delete - clear the valid bit */
505		qp = QAM_GET_RECORD(file_dbp, pagep, argp->indx);
506		F_CLR(qp, QAM_VALID);
507		/*
508		 * We only move the LSN forward during replication.
509		 * During recovery we could obscure an update from
510		 * a partially completed transaction while processing
511		 * a hot backup.  [#13823]
512		 */
513		if (op == DB_TXN_APPLY)
514			LSN(pagep) = *lsnp;
515	}
516	if ((ret = __qam_fput(dbc, argp->pgno, pagep, dbc->priority)) != 0)
517		goto out;
518
519done:	*lsnp = argp->prev_lsn;
520	ret = 0;
521
522	if (0) {
523err:		(void)__qam_fput(dbc, argp->pgno, pagep, dbc->priority);
524	}
525out:	REC_CLOSE;
526}
527
528/*
529 * __qam_add_recover --
530 *	Recovery function for add.
531 *
532 * PUBLIC: int __qam_add_recover
533 * PUBLIC:      __P((ENV *, DBT *, DB_LSN *, db_recops, void *));
534 */
535int
536__qam_add_recover(env, dbtp, lsnp, op, info)
537	ENV *env;
538	DBT *dbtp;
539	DB_LSN *lsnp;
540	db_recops op;
541	void *info;
542{
543	__qam_add_args *argp;
544	DB_THREAD_INFO *ip;
545	DB *file_dbp;
546	DBC *dbc;
547	DB_MPOOLFILE *mpf;
548	QAMDATA *qp;
549	QMETA *meta;
550	QPAGE *pagep;
551	db_pgno_t metapg;
552	int cmp_n, ret;
553
554	COMPQUIET(pagep, NULL);
555
556	ip = ((DB_TXNHEAD *)info)->thread_info;
557	REC_PRINT(__qam_add_print);
558	REC_INTRO(__qam_add_read, ip, 1);
559
560	if ((ret = __qam_fget(dbc, &argp->pgno,
561	     DB_UNDO(op) ? 0 : DB_MPOOL_CREATE, &pagep)) != 0) {
562		/*
563		 * If we are undoing an append and the page is not there
564		 * we are done.
565		 */
566		if (DB_UNDO(op) && (ret == DB_PAGE_NOTFOUND || ret == ENOENT))
567			goto done;
568		goto out;
569	}
570
571	if (pagep->pgno == PGNO_INVALID) {
572		QAM_DIRTY(dbc, argp->pgno, &pagep);
573		pagep->pgno = argp->pgno;
574		pagep->type = P_QAMDATA;
575	}
576
577	cmp_n = LOG_COMPARE(lsnp, &LSN(pagep));
578
579	if (DB_REDO(op)) {
580		/* Fix meta-data page. */
581		metapg = ((QUEUE *)file_dbp->q_internal)->q_meta;
582		if ((ret = __memp_fget(mpf, &metapg, ip, NULL,
583		    0, &meta)) != 0)
584			goto err;
585		if (QAM_BEFORE_FIRST(meta, argp->recno)) {
586			REC_DIRTY(mpf, ip, dbc->priority, &meta);
587			meta->first_recno = argp->recno;
588		}
589		if (argp->recno == meta->cur_recno ||
590		    QAM_AFTER_CURRENT(meta, argp->recno)) {
591			REC_DIRTY(mpf, ip, dbc->priority, &meta);
592			meta->cur_recno = argp->recno + 1;
593		}
594		if ((ret = __memp_fput(mpf, ip, meta, dbc->priority)) != 0)
595			goto err;
596
597		/* Now update the actual page if necessary. */
598		if (op == DB_TXN_APPLY || cmp_n > 0) {
599			QAM_DIRTY(dbc, pagep->pgno, &pagep);
600			/* Need to redo add - put the record on page */
601			if ((ret = __qam_pitem(dbc,
602			    pagep, argp->indx, argp->recno, &argp->data)) != 0)
603				goto err;
604			/*
605			 * We only move the LSN forward during replication.
606			 * During recovery we could obscure an update from
607			 * a partially completed transaction while processing
608			 * a hot backup.  [#13823]
609			 */
610			if (op == DB_TXN_APPLY)
611				LSN(pagep) = *lsnp;
612		}
613	} else if (DB_UNDO(op)) {
614		/*
615		 * Need to undo add
616		 *	If this was an overwrite, put old record back.
617		 *	Otherwise just clear the valid bit
618		 */
619		if (argp->olddata.size != 0) {
620			QAM_DIRTY(dbc, pagep->pgno, &pagep);
621			if ((ret = __qam_pitem(dbc, pagep,
622			    argp->indx, argp->recno, &argp->olddata)) != 0)
623				goto err;
624
625			if (!(argp->vflag & QAM_VALID)) {
626				qp = QAM_GET_RECORD(
627				    file_dbp, pagep, argp->indx);
628				F_CLR(qp, QAM_VALID);
629			}
630		} else {
631			QAM_DIRTY(dbc, pagep->pgno, &pagep);
632			qp = QAM_GET_RECORD(file_dbp, pagep, argp->indx);
633			qp->flags = 0;
634		}
635
636		/*
637		 * Move the LSN back to this point;  do not move it forward.
638		 * If we're in an abort, because we don't hold a page lock,
639		 * we could foul up a concurrent put.  Having too late an
640		 * LSN is harmless in queue except when we're determining
641		 * what we need to roll forward during recovery.  [#2588]
642		 */
643		if (cmp_n <= 0 && op == DB_TXN_BACKWARD_ROLL)
644			LSN(pagep) = argp->lsn;
645	}
646
647	if ((ret = __qam_fput(dbc, argp->pgno, pagep, dbc->priority)) != 0)
648		goto out;
649
650done:	*lsnp = argp->prev_lsn;
651	ret = 0;
652
653	if (0) {
654err:		(void)__qam_fput(dbc, argp->pgno, pagep, dbc->priority);
655	}
656
657out:	REC_CLOSE;
658}
659