summaryrefslogtreecommitdiff
path: root/db/rep/rep_util.c
diff options
context:
space:
mode:
Diffstat (limited to 'db/rep/rep_util.c')
-rw-r--r--db/rep/rep_util.c453
1 files changed, 186 insertions, 267 deletions
diff --git a/db/rep/rep_util.c b/db/rep/rep_util.c
index 678edbcee..d23a6aba3 100644
--- a/db/rep/rep_util.c
+++ b/db/rep/rep_util.c
@@ -1,30 +1,31 @@
/*-
- * See the file LICENSE for redistribution information.
- *
- * Copyright (c) 2001-2003
+ * See the file LICENSE for redistribution information. *
+ * Copyright (c) 2001-2004
* Sleepycat Software. All rights reserved.
+ *
+ * $Id: rep_util.c,v 1.134 2004/10/12 15:42:43 sue Exp $
*/
#include "db_config.h"
-#ifndef lint
-static const char revid[] = "$Id: rep_util.c,v 1.103 2003/11/14 05:32:32 ubell Exp $";
-#endif /* not lint */
-
#ifndef NO_SYSTEM_INCLUDES
+#if TIME_WITH_SYS_TIME
+#include <sys/time.h>
+#include <time.h>
+#else
+#if HAVE_SYS_TIME_H
+#include <sys/time.h>
+#else
+#include <time.h>
+#endif
+#endif
+
#include <stdlib.h>
#include <string.h>
#endif
#include "db_int.h"
-#include "dbinc/db_page.h"
-#include "dbinc/db_shash.h"
-#include "dbinc/btree.h"
-#include "dbinc/fop.h"
-#include "dbinc/hash.h"
#include "dbinc/log.h"
-#include "dbinc/lock.h"
-#include "dbinc/qam.h"
#include "dbinc/txn.h"
/*
@@ -33,40 +34,22 @@ static const char revid[] = "$Id: rep_util.c,v 1.103 2003/11/14 05:32:32 ubell E
* those called by other subsystems.
*/
+#define TIMESTAMP_CHECK(dbenv, ts, renv) \
+do { \
+ if (renv->op_timestamp != 0 && \
+ renv->op_timestamp + DB_REGENV_TIMEOUT < ts) { \
+ MUTEX_LOCK(dbenv, &renv->mutex); \
+ F_CLR(renv, DB_REGENV_REPLOCKED); \
+ renv->op_timestamp = 0; \
+ MUTEX_UNLOCK(dbenv, &renv->mutex); \
+ } \
+} while (0)
+
#ifdef REP_DIAGNOSTIC
static void __rep_print_logmsg __P((DB_ENV *, const DBT *, DB_LSN *));
#endif
/*
- * __rep_check_alloc --
- * Make sure the array of TXN_REC entries is of at least size n.
- * (This function is called by the __*_getpgnos() functions in
- * *.src.)
- *
- * PUBLIC: int __rep_check_alloc __P((DB_ENV *, TXN_RECS *, int));
- */
-int
-__rep_check_alloc(dbenv, r, n)
- DB_ENV *dbenv;
- TXN_RECS *r;
- int n;
-{
- int nalloc, ret;
-
- while (r->nalloc < r->npages + n) {
- nalloc = r->nalloc == 0 ? 20 : r->nalloc * 2;
-
- if ((ret = __os_realloc(dbenv, nalloc * sizeof(LSN_PAGE),
- &r->array)) != 0)
- return (ret);
-
- r->nalloc = nalloc;
- }
-
- return (0);
-}
-
-/*
* __rep_send_message --
* This is a wrapper for sending a message. It takes care of constructing
* the REP_CONTROL structure and calling the user's specified send function.
@@ -89,6 +72,9 @@ __rep_send_message(dbenv, eid, rtype, lsnp, dbtp, flags)
REP_CONTROL cntrl;
int ret;
u_int32_t myflags, rectype;
+#ifdef DIAGNOSTIC
+ DB_MSGBUF mb;
+#endif
db_rep = dbenv->rep_handle;
rep = db_rep->region;
@@ -103,9 +89,7 @@ __rep_send_message(dbenv, eid, rtype, lsnp, dbtp, flags)
cntrl.flags = flags;
cntrl.rep_version = DB_REPVERSION;
cntrl.log_version = DB_LOGVERSION;
- MUTEX_LOCK(dbenv, db_rep->rep_mutexp);
cntrl.gen = rep->gen;
- MUTEX_UNLOCK(dbenv, db_rep->rep_mutexp);
memset(&cdbt, 0, sizeof(cdbt));
cdbt.data = &cntrl;
@@ -117,10 +101,7 @@ __rep_send_message(dbenv, eid, rtype, lsnp, dbtp, flags)
dbtp = &scrap_dbt;
}
-#ifdef DIAGNOSTIC
- if (FLD_ISSET(dbenv->verbose, DB_VERB_REPLICATION))
- __rep_print_message(dbenv, eid, &cntrl, "rep_send_message");
-#endif
+ REP_PRINT_MESSAGE(dbenv, eid, &cntrl, "rep_send_message");
#ifdef REP_DIAGNOSTIC
if (rtype == REP_LOG)
__rep_print_logmsg(dbenv, dbtp, lsnp);
@@ -135,9 +116,9 @@ __rep_send_message(dbenv, eid, rtype, lsnp, dbtp, flags)
myflags = 0;
if (LF_ISSET(DB_LOG_PERM))
myflags = DB_REP_PERMANENT;
- else if (rtype != REP_LOG)
+ else if (rtype != REP_LOG || LF_ISSET(DB_LOG_RESEND))
myflags = DB_REP_NOBUFFER;
- else {
+ if (rtype == REP_LOG && !LF_ISSET(DB_LOG_PERM)) {
/*
* Check if this is a log record we just read that
* may need a DB_LOG_PERM. This is of type REP_LOG,
@@ -162,13 +143,11 @@ __rep_send_message(dbenv, eid, rtype, lsnp, dbtp, flags)
*/
if (ret == 0)
rep->stat.st_msgs_sent++;
- else
+ else {
rep->stat.st_msgs_send_failures++;
-
-#ifdef DIAGNOSTIC
- if (ret != 0 && FLD_ISSET(dbenv->verbose, DB_VERB_REPLICATION))
- __db_err(dbenv, "rep_send_function returned: %d", ret);
-#endif
+ RPRINT(dbenv, rep, (dbenv, &mb,
+ "rep_send_function returned: %d", ret));
+ }
return (ret);
}
@@ -227,48 +206,51 @@ __rep_new_master(dbenv, cntrl, eid)
int eid;
{
DB_LOG *dblp;
- DB_LOGC *logc;
- DB_LSN last_lsn, lsn;
+ DB_LSN ckp_lsn, lsn;
DB_REP *db_rep;
- DBT dbt;
+ DB_TXNMGR *mgr;
+ DB_TXNREGION *region;
LOG *lp;
+ REGENV *renv;
+ REGINFO *infop;
REP *rep;
- int change, ret, t_ret;
+ int change, do_req, ret;
+#ifdef DIAGNOSTIC
+ DB_MSGBUF mb;
+#endif
db_rep = dbenv->rep_handle;
+ mgr = dbenv->tx_handle;
+ region = mgr->reginfo.primary;
rep = db_rep->region;
ret = 0;
MUTEX_LOCK(dbenv, db_rep->rep_mutexp);
__rep_elect_done(dbenv, rep);
change = rep->gen != cntrl->gen || rep->master_id != eid;
if (change) {
-#ifdef DIAGNOSTIC
- if (FLD_ISSET(dbenv->verbose, DB_VERB_REPLICATION))
- __db_err(dbenv,
- "Updating gen from %lu to %lu from master %d",
- (u_long)rep->gen, (u_long)cntrl->gen, eid);
-#endif
+ RPRINT(dbenv, rep, (dbenv, &mb,
+ "Updating gen from %lu to %lu from master %d",
+ (u_long)rep->gen, (u_long)cntrl->gen, eid));
rep->gen = cntrl->gen;
if (rep->egen <= rep->gen)
rep->egen = rep->gen + 1;
-#ifdef DIAGNOSTIC
- if (FLD_ISSET(dbenv->verbose, DB_VERB_REPLICATION))
- __db_err(dbenv,
- "Updating egen to %lu", (u_long)rep->egen);
-#endif
+ RPRINT(dbenv, rep, (dbenv, &mb,
+ "Egen is %lu", (u_long)rep->egen));
rep->master_id = eid;
rep->stat.st_master_changes++;
- F_SET(rep, REP_F_NOARCHIVE | REP_F_RECOVER);
+ rep->stat.st_startup_complete = 0;
+ F_SET(rep, REP_F_NOARCHIVE | REP_F_RECOVER_VERIFY);
}
MUTEX_UNLOCK(dbenv, db_rep->rep_mutexp);
dblp = dbenv->lg_handle;
lp = dblp->reginfo.primary;
R_LOCK(dbenv, &dblp->reginfo);
- last_lsn = lsn = lp->lsn;
- if (last_lsn.offset > sizeof(LOGP))
- last_lsn.offset -= lp->len;
+ lsn = lp->lsn;
R_UNLOCK(dbenv, &dblp->reginfo);
+ R_LOCK(dbenv, &mgr->reginfo);
+ ckp_lsn = region->last_ckp;
+ R_UNLOCK(dbenv, &mgr->reginfo);
if (!change) {
/*
@@ -276,15 +258,17 @@ __rep_new_master(dbenv, cntrl, eid)
* catching up or verification to do.
*/
ret = 0;
- if (F_ISSET(rep, REP_F_RECOVER)) {
- MUTEX_LOCK(dbenv, db_rep->db_mutexp);
+ MUTEX_LOCK(dbenv, db_rep->db_mutexp);
+ do_req = __rep_check_doreq(dbenv, rep);
+ if (F_ISSET(rep, REP_F_RECOVER_VERIFY)) {
lsn = lp->verify_lsn;
MUTEX_UNLOCK(dbenv, db_rep->db_mutexp);
- if (!IS_ZERO_LSN(lsn))
+ if (!IS_ZERO_LSN(lsn) && do_req)
(void)__rep_send_message(dbenv, eid,
- REP_VERIFY_REQ, &last_lsn, NULL, 0);
+ REP_VERIFY_REQ, &lsn, NULL, 0);
} else {
- if (log_compare(&lsn, &cntrl->lsn) < 0)
+ MUTEX_UNLOCK(dbenv, db_rep->db_mutexp);
+ if (log_compare(&lsn, &cntrl->lsn) < 0 && do_req)
(void)__rep_send_message(dbenv,
eid, REP_ALL_REQ, &lsn, NULL, 0);
MUTEX_LOCK(dbenv, db_rep->rep_mutexp);
@@ -302,49 +286,45 @@ __rep_new_master(dbenv, cntrl, eid)
* the master is not, then we just need to request all the log
* records from the master.
*/
- if (IS_INIT_LSN(lsn) || IS_ZERO_LSN(lsn)) {
-empty: MUTEX_LOCK(dbenv, db_rep->rep_mutexp);
- F_CLR(rep, REP_F_NOARCHIVE | REP_F_READY | REP_F_RECOVER);
+ if (IS_INIT_LSN(lsn) || IS_ZERO_LSN(lsn) || IS_ZERO_LSN(ckp_lsn)) {
+ /*
+ * If we don't have a checkpoint, we still might have
+ * some log records but we're discarding them to sync
+ * up with the master from the start. Therefore,
+ * truncate our log.
+ */
+ if (IS_ZERO_LSN(ckp_lsn)) {
+ INIT_LSN(lsn);
+ (void)__log_vtruncate(dbenv, &lsn, &ckp_lsn, NULL);
+ infop = dbenv->reginfo;
+ renv = infop->primary;
+ (void)time(&renv->rep_timestamp);
+ }
+
+ /*
+ * If we have no log, then we have no files to open
+ * in recovery, but we've opened what we can, which
+ * is none. Mark DBREP_OPENFILES here.
+ */
+ MUTEX_LOCK(dbenv, db_rep->db_mutexp);
+ F_SET(db_rep, DBREP_OPENFILES);
+ MUTEX_LOCK(dbenv, db_rep->rep_mutexp);
+ F_CLR(rep, REP_F_NOARCHIVE | REP_F_RECOVER_MASK);
MUTEX_UNLOCK(dbenv, db_rep->rep_mutexp);
+ MUTEX_UNLOCK(dbenv, db_rep->db_mutexp);
if (!IS_INIT_LSN(cntrl->lsn))
(void)__rep_send_message(dbenv, rep->master_id,
REP_ALL_REQ, &lsn, NULL, 0);
return (DB_REP_NEWMASTER);
- } else if (last_lsn.offset <= sizeof(LOGP)) {
- /*
- * We have just changed log files and need to set lastlsn
- * to the last record in the previous log files.
- */
- if ((ret = __log_cursor(dbenv, &logc)) != 0)
- return (ret);
- memset(&dbt, 0, sizeof(dbt));
- ret = __log_c_get(logc, &last_lsn, &dbt, DB_LAST);
- if ((t_ret = __log_c_close(logc)) != 0 && ret == 0)
- ret = t_ret;
- if (ret == DB_NOTFOUND)
- goto empty;
- if (ret != 0) {
- /*
- * We failed here and if we set recover above,
- * we'd better clear it, because we haven't
- * set the verify LSN
- */
- if (change) {
- MUTEX_LOCK(dbenv, db_rep->rep_mutexp);
- F_CLR(rep, REP_F_RECOVER);
- MUTEX_UNLOCK(dbenv, db_rep->rep_mutexp);
- }
- return (ret);
- }
}
MUTEX_LOCK(dbenv, db_rep->db_mutexp);
- lp->verify_lsn = last_lsn;
+ lp->verify_lsn = ckp_lsn;
MUTEX_UNLOCK(dbenv, db_rep->db_mutexp);
(void)__rep_send_message(dbenv,
- eid, REP_VERIFY_REQ, &last_lsn, NULL, 0);
+ eid, REP_VERIFY_REQ, &ckp_lsn, NULL, 0);
return (DB_REP_NEWMASTER);
}
@@ -362,17 +342,18 @@ __rep_is_client(dbenv)
{
DB_REP *db_rep;
REP *rep;
- int ret;
if (!REP_ON(dbenv))
return (0);
+
db_rep = dbenv->rep_handle;
rep = db_rep->region;
- MUTEX_LOCK(dbenv, db_rep->rep_mutexp);
- ret = F_ISSET(rep, REP_F_UPGRADE | REP_F_LOGSONLY);
- MUTEX_UNLOCK(dbenv, db_rep->rep_mutexp);
- return (ret);
+ /*
+ * Don't just return F_ISSET since that converts unsigned
+ * into signed.
+ */
+ return (F_ISSET(rep, REP_F_CLIENT) ? 1 : 0);
}
/*
@@ -387,14 +368,31 @@ __rep_noarchive(dbenv)
DB_ENV *dbenv;
{
DB_REP *db_rep;
+ REGENV *renv;
+ REGINFO *infop;
REP *rep;
+ time_t timestamp;
if (!REP_ON(dbenv))
return (0);
db_rep = dbenv->rep_handle;
rep = db_rep->region;
+ infop = dbenv->reginfo;
+ renv = infop->primary;
- return (F_ISSET(rep, REP_F_NOARCHIVE));
+ if (F_ISSET(rep, REP_F_NOARCHIVE))
+ return (1);
+ if (F_ISSET(renv, DB_REGENV_REPLOCKED)) {
+ (void)time(&timestamp);
+ TIMESTAMP_CHECK(dbenv, timestamp, renv);
+ /*
+ * Check if we're still locked out after checking
+ * the timestamp.
+ */
+ if (F_ISSET(renv, DB_REGENV_REPLOCKED))
+ return (EINVAL);
+ }
+ return (0);
}
/*
@@ -402,14 +400,14 @@ __rep_noarchive(dbenv)
* Send this site's vote for the election.
*
* PUBLIC: void __rep_send_vote __P((DB_ENV *, DB_LSN *, int, int, int,
- * PUBLIC: u_int32_t, int, u_int32_t));
+ * PUBLIC: u_int32_t, u_int32_t, int, u_int32_t));
*/
void
-__rep_send_vote(dbenv, lsnp, nsites, pri, tiebreaker, egen, eid, vtype)
+__rep_send_vote(dbenv, lsnp, nsites, nvotes, pri, tie, egen, eid, vtype)
DB_ENV *dbenv;
DB_LSN *lsnp;
- int eid, nsites, pri, tiebreaker;
- u_int32_t egen, vtype;
+ int eid, nsites, nvotes, pri;
+ u_int32_t egen, tie, vtype;
{
DBT vote_dbt;
REP_VOTE_INFO vi;
@@ -419,7 +417,8 @@ __rep_send_vote(dbenv, lsnp, nsites, pri, tiebreaker, egen, eid, vtype)
vi.egen = egen;
vi.priority = pri;
vi.nsites = nsites;
- vi.tiebreaker = tiebreaker;
+ vi.nvotes = nvotes;
+ vi.tiebreaker = tie;
memset(&vote_dbt, 0, sizeof(vote_dbt));
vote_dbt.data = &vi;
@@ -441,21 +440,19 @@ __rep_elect_done(dbenv, rep)
REP *rep;
{
int inelect;
-
-#ifndef DIAGNOSTIC
+#ifdef DIAGNOSTIC
+ DB_MSGBUF mb;
+#else
COMPQUIET(dbenv, NULL);
#endif
-
inelect = IN_ELECTION_TALLY(rep);
F_CLR(rep, REP_F_EPHASE1 | REP_F_EPHASE2 | REP_F_TALLY);
rep->sites = 0;
rep->votes = 0;
if (inelect)
rep->egen++;
-#ifdef DIAGNOSTIC
- if (FLD_ISSET(dbenv->verbose, DB_VERB_REPLICATION))
- __db_err(dbenv, "Election done; egen %lu", (u_long)rep->egen);
-#endif
+ RPRINT(dbenv, rep, (dbenv, &mb,
+ "Election done; egen %lu", (u_long)rep->egen));
}
/*
@@ -496,21 +493,21 @@ __rep_grow_sites(dbenv, nsites)
* one for VOTE2's. Always grow them in tandem, because if we
* get more VOTE1's we'll always expect more VOTE2's then too.
*/
- if ((ret = __db_shalloc(infop->addr,
- nalloc * sizeof(REP_VTALLY), sizeof(REP_VTALLY),
+ if ((ret = __db_shalloc(infop,
+ (size_t)nalloc * sizeof(REP_VTALLY), sizeof(REP_VTALLY),
&tally)) == 0) {
if (rep->tally_off != INVALID_ROFF)
- __db_shalloc_free(infop->addr,
- R_ADDR(infop, rep->tally_off));
- rep->tally_off = R_OFFSET(infop, tally);
- if ((ret = __db_shalloc(infop->addr,
- nalloc * sizeof(REP_VTALLY), sizeof(REP_VTALLY),
+ __db_shalloc_free(
+ infop, R_ADDR(dbenv, infop, rep->tally_off));
+ rep->tally_off = R_OFFSET(dbenv, infop, tally);
+ if ((ret = __db_shalloc(infop,
+ (size_t)nalloc * sizeof(REP_VTALLY), sizeof(REP_VTALLY),
&tally)) == 0) {
/* Success */
if (rep->v2tally_off != INVALID_ROFF)
- __db_shalloc_free(infop->addr,
- R_ADDR(infop, rep->v2tally_off));
- rep->v2tally_off = R_OFFSET(infop, tally);
+ __db_shalloc_free(infop,
+ R_ADDR(dbenv, infop, rep->v2tally_off));
+ rep->v2tally_off = R_OFFSET(dbenv, infop, tally);
rep->asites = nalloc;
rep->nsites = nsites;
} else {
@@ -522,10 +519,10 @@ __rep_grow_sites(dbenv, nsites)
* to the error.
*/
if (rep->v2tally_off != INVALID_ROFF)
- __db_shalloc_free(infop->addr,
- R_ADDR(infop, rep->v2tally_off));
- __db_shalloc_free(infop->addr,
- R_ADDR(infop, rep->tally_off));
+ __db_shalloc_free(infop,
+ R_ADDR(dbenv, infop, rep->v2tally_off));
+ __db_shalloc_free(infop,
+ R_ADDR(dbenv, infop, rep->tally_off));
rep->v2tally_off = rep->tally_off = INVALID_ROFF;
rep->asites = 0;
rep->nsites = 0;
@@ -563,7 +560,7 @@ __env_rep_enter(dbenv)
MUTEX_LOCK(dbenv, db_rep->rep_mutexp);
for (cnt = 0; rep->in_recovery;) {
MUTEX_UNLOCK(dbenv, db_rep->rep_mutexp);
- (void)__os_sleep(dbenv, 1, 0);
+ __os_sleep(dbenv, 1, 0);
MUTEX_LOCK(dbenv, db_rep->rep_mutexp);
if (++cnt % 60 == 0)
__db_err(dbenv,
@@ -575,14 +572,14 @@ __env_rep_enter(dbenv)
}
/*
- * __env_rep_exit --
+ * __env_db_rep_exit --
*
* Decrement handle count upon routine exit.
*
- * PUBLIC: void __env_rep_exit __P((DB_ENV *));
+ * PUBLIC: void __env_db_rep_exit __P((DB_ENV *));
*/
void
-__env_rep_exit(dbenv)
+__env_db_rep_exit(dbenv)
DB_ENV *dbenv;
{
DB_REP *db_rep;
@@ -608,34 +605,49 @@ __env_rep_exit(dbenv)
* If return_now is non-zero, we'll return DB_DEADLOCK immediately, else we'll
* sleep before returning DB_DEADLOCK.
*
- * PUBLIC: int __db_rep_enter __P((DB *, int, int));
+ * PUBLIC: int __db_rep_enter __P((DB *, int, int, int));
*/
int
-__db_rep_enter(dbp, checkgen, return_now)
+__db_rep_enter(dbp, checkgen, checklock, return_now)
DB *dbp;
- int checkgen, return_now;
+ int checkgen, checklock, return_now;
{
DB_ENV *dbenv;
DB_REP *db_rep;
+ REGENV *renv;
+ REGINFO *infop;
REP *rep;
+ time_t timestamp;
dbenv = dbp->dbenv;
- /* Check if locks have been globally turned off. */
+ /* Check if locks have been globally turned off. */
if (F_ISSET(dbenv, DB_ENV_NOLOCKING))
return (0);
db_rep = dbenv->rep_handle;
rep = db_rep->region;
+ infop = dbenv->reginfo;
+ renv = infop->primary;
+ if (checklock && F_ISSET(renv, DB_REGENV_REPLOCKED)) {
+ (void)time(&timestamp);
+ TIMESTAMP_CHECK(dbenv, timestamp, renv);
+ /*
+ * Check if we're still locked out after checking
+ * the timestamp.
+ */
+ if (F_ISSET(renv, DB_REGENV_REPLOCKED))
+ return (EINVAL);
+ }
MUTEX_LOCK(dbenv, db_rep->rep_mutexp);
if (F_ISSET(rep, REP_F_READY)) {
MUTEX_UNLOCK(dbenv, db_rep->rep_mutexp);
if (!return_now)
- (void)__os_sleep(dbenv, 5, 0);
+ __os_sleep(dbenv, 5, 0);
return (DB_LOCK_DEADLOCK);
}
- if (checkgen && dbp->timestamp != rep->timestamp) {
+ if (checkgen && dbp->timestamp != renv->rep_timestamp) {
MUTEX_UNLOCK(dbenv, db_rep->rep_mutexp);
__db_err(dbenv, "%s %s",
"replication recovery unrolled committed transactions;",
@@ -649,31 +661,6 @@ __db_rep_enter(dbp, checkgen, return_now)
}
/*
- * __db_rep_exit --
- * Decrement handle counts.
- *
- * PUBLIC: void __db_rep_exit __P((DB_ENV *));
- */
-void
-__db_rep_exit(dbenv)
- DB_ENV *dbenv;
-{
- DB_REP *db_rep;
- REP *rep;
-
- /* Check if locks have been globally turned off. */
- if (F_ISSET(dbenv, DB_ENV_NOLOCKING))
- return;
-
- db_rep = dbenv->rep_handle;
- rep = db_rep->region;
-
- MUTEX_LOCK(dbenv, db_rep->rep_mutexp);
- rep->handle_cnt--;
- MUTEX_UNLOCK(dbenv, db_rep->rep_mutexp);
-}
-
-/*
* __op_rep_enter --
*
* Check if we are in the middle of replication initialization and/or
@@ -702,7 +689,7 @@ __op_rep_enter(dbenv)
MUTEX_LOCK(dbenv, db_rep->rep_mutexp);
for (cnt = 0; F_ISSET(rep, REP_F_READY);) {
MUTEX_UNLOCK(dbenv, db_rep->rep_mutexp);
- (void)__os_sleep(dbenv, 5, 0);
+ __os_sleep(dbenv, 5, 0);
MUTEX_LOCK(dbenv, db_rep->rep_mutexp);
if (++cnt % 60 == 0)
__db_err(dbenv,
@@ -717,7 +704,7 @@ __op_rep_enter(dbenv)
* __op_rep_exit --
*
* Decrement op count upon transaction commit/abort/discard or
- * memp_fput.
+ * memp_fput.
*
* PUBLIC: void __op_rep_exit __P((DB_ENV *));
*/
@@ -767,86 +754,6 @@ __rep_get_gen(dbenv, genp)
MUTEX_UNLOCK(dbenv, db_rep->rep_mutexp);
}
-#ifdef NOTYET
-static int __rep_send_file __P((DB_ENV *, DBT *, u_int32_t));
-/*
- * __rep_send_file --
- * Send an entire file, one block at a time.
- */
-static int
-__rep_send_file(dbenv, rec, eid)
- DB_ENV *dbenv;
- DBT *rec;
- u_int32_t eid;
-{
- DB *dbp;
- DB_LOCK lk;
- DB_MPOOLFILE *mpf;
- DBC *dbc;
- DBT rec_dbt;
- PAGE *pagep;
- db_pgno_t last_pgno, pgno;
- int ret, t_ret;
-
- dbp = NULL;
- dbc = NULL;
- pagep = NULL;
- mpf = NULL;
- LOCK_INIT(lk);
-
- if ((ret = db_create(&dbp, dbenv, 0)) != 0)
- goto err;
-
- if ((ret = __db_open(
- dbp, rec->data, NULL, DB_UNKNOWN, 0, 0, PGNO_BASE_MD)) != 0)
- goto err;
-
- if ((ret = __db_cursor(dbp, NULL, &dbc, 0)) != 0)
- goto err;
- /*
- * Force last_pgno to some value that will let us read the meta-dat
- * page in the following loop.
- */
- memset(&rec_dbt, 0, sizeof(rec_dbt));
- last_pgno = 1;
- for (pgno = 0; pgno <= last_pgno; pgno++) {
- if ((ret = __db_lget(dbc, 0, pgno, DB_LOCK_READ, 0, &lk)) != 0)
- goto err;
-
- if ((ret = __memp_fget(mpf, &pgno, 0, &pagep)) != 0)
- goto err;
-
- if (pgno == 0)
- last_pgno = ((DBMETA *)pagep)->last_pgno;
-
- rec_dbt.data = pagep;
- rec_dbt.size = dbp->pgsize;
- if (__rep_send_message(dbenv, eid,
- REP_FILE, NULL, &rec_dbt, pgno == last_pgno) != 0)
- break;
- ret = __memp_fput(mpf, pagep, 0);
- pagep = NULL;
- if (ret != 0)
- goto err;
- ret = __LPUT(dbc, lk);
- LOCK_INIT(lk);
- if (ret != 0)
- goto err;
- }
-
-err: if (LOCK_ISSET(lk) && (t_ret = __LPUT(dbc, lk)) != 0 && ret == 0)
- ret = t_ret;
- if (dbc != NULL && (t_ret = __db_c_close(dbc)) != 0 && ret == 0)
- ret = t_ret;
- if (pagep != NULL &&
- (t_ret = __memp_fput(mpf, pagep, 0)) != 0 && ret == 0)
- ret = t_ret;
- if (dbp != NULL && (t_ret = __db_close(dbp, NULL, 0)) != 0 && ret == 0)
- ret = t_ret;
- return (ret);
-}
-#endif
-
#ifdef DIAGNOSTIC
/*
* PUBLIC: void __rep_print_message __P((DB_ENV *, int, REP_CONTROL *, char *));
@@ -858,7 +765,9 @@ __rep_print_message(dbenv, eid, rp, str)
REP_CONTROL *rp;
char *str;
{
+ DB_MSGBUF mb;
char *type;
+
switch (rp->rectype) {
case REP_ALIVE:
type = "alive";
@@ -875,6 +784,9 @@ __rep_print_message(dbenv, eid, rp, str)
case REP_FILE:
type = "file";
break;
+ case REP_FILE_FAIL:
+ type = "file_fail";
+ break;
case REP_FILE_REQ:
type = "file_req";
break;
@@ -905,14 +817,20 @@ __rep_print_message(dbenv, eid, rp, str)
case REP_PAGE:
type = "page";
break;
+ case REP_PAGE_FAIL:
+ type = "page_fail";
+ break;
+ case REP_PAGE_MORE:
+ type = "page_more";
+ break;
case REP_PAGE_REQ:
type = "page_req";
break;
- case REP_PLIST:
- type = "plist";
+ case REP_UPDATE:
+ type = "update";
break;
- case REP_PLIST_REQ:
- type = "plist_req";
+ case REP_UPDATE_REQ:
+ type = "update_req";
break;
case REP_VERIFY:
type = "verify";
@@ -933,8 +851,9 @@ __rep_print_message(dbenv, eid, rp, str)
type = "NOTYPE";
break;
}
- __db_err(dbenv, "%s %s: gen = %lu eid %d, type %s, LSN [%lu][%lu]",
+ RPRINT(dbenv, ((REP *)((DB_REP *)(dbenv)->rep_handle)->region),
+ (dbenv, &mb, "%s %s: gen = %lu eid %d, type %s, LSN [%lu][%lu]",
dbenv->db_home, str, (u_long)rp->gen,
- eid, type, (u_long)rp->lsn.file, (u_long)rp->lsn.offset);
+ eid, type, (u_long)rp->lsn.file, (u_long)rp->lsn.offset));
}
#endif