Fix recovery mode, there were multiple issues:
1. the btree filename was not set so that we always used a transient in-memory db for the data 2. we did not call sync after creation with R_RECNOSYNC so that the header of the btree was never written 3. we did not call the right flavor of sync before copying the tree to the preserved files
This commit is contained in:
parent
0c38cb8432
commit
0481af84d9
12
external/bsd/nvi/dist/common/recover.c
vendored
12
external/bsd/nvi/dist/common/recover.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: recover.c,v 1.3 2013/11/27 21:17:36 christos Exp $ */
|
||||
/* $NetBSD: recover.c,v 1.4 2013/11/30 14:54:29 christos Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 1993, 1994
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
@ -260,7 +260,15 @@ rcv_sync(SCR *sp, u_int flags)
|
||||
|
||||
/* Sync the file if it's been modified. */
|
||||
if (F_ISSET(ep, F_MODIFIED)) {
|
||||
if (ep->db->sync(ep->db, 0)) {
|
||||
/*
|
||||
* If we are using a db1 version of the database,
|
||||
* we want to sync the underlying btree not the
|
||||
* recno tree which is transient anyway.
|
||||
*/
|
||||
#ifndef R_RECNOSYNC
|
||||
#define R_RECNOSYNC 0
|
||||
#endif
|
||||
if (ep->db->sync(ep->db, R_RECNOSYNC)) {
|
||||
F_CLR(ep, F_RCV_ON | F_RCV_NORM);
|
||||
msgq_str(sp, M_SYSERR,
|
||||
ep->rcv_path, "060|File backup failed: %s");
|
||||
|
23
external/bsd/nvi/dist/common/vi_db1.c
vendored
23
external/bsd/nvi/dist/common/vi_db1.c
vendored
@ -685,10 +685,19 @@ db_init(SCR *sp, EXF *ep, char *rcv_name, char *oname, size_t psize, int *open_e
|
||||
|
||||
memset(&oinfo, 0, sizeof(RECNOINFO));
|
||||
oinfo.bval = '\n'; /* Always set. */
|
||||
oinfo.psize = psize;
|
||||
oinfo.flags = R_SNAPSHOT;
|
||||
if (rcv_name)
|
||||
oinfo.bfname = ep->rcv_path;
|
||||
/*
|
||||
* If we are not recovering, set the pagesize and arrange to
|
||||
* first get a snapshot of the file.
|
||||
*/
|
||||
if (rcv_name == NULL) {
|
||||
oinfo.psize = psize;
|
||||
oinfo.flags = R_SNAPSHOT;
|
||||
}
|
||||
/*
|
||||
* Always set the btree name, otherwise we are going to be using
|
||||
* an in-memory database for the btree.
|
||||
*/
|
||||
oinfo.bfname = ep->rcv_path;
|
||||
|
||||
#define _DB_OPEN_MODE S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH
|
||||
|
||||
@ -709,6 +718,12 @@ db_init(SCR *sp, EXF *ep, char *rcv_name, char *oname, size_t psize, int *open_e
|
||||
|
||||
*open_err = 1;
|
||||
return 1;
|
||||
} else {
|
||||
/*
|
||||
* We always sync the underlying btree so that the header
|
||||
* is written first
|
||||
*/
|
||||
ep->db->sync(ep->db, R_RECNOSYNC);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user