summaryrefslogtreecommitdiff
path: root/src/dbinc/db_int.in
diff options
context:
space:
mode:
Diffstat (limited to 'src/dbinc/db_int.in')
-rw-r--r--src/dbinc/db_int.in140
1 files changed, 91 insertions, 49 deletions
diff --git a/src/dbinc/db_int.in b/src/dbinc/db_int.in
index 42439107..593deef6 100644
--- a/src/dbinc/db_int.in
+++ b/src/dbinc/db_int.in
@@ -1,7 +1,7 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 1996, 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2015 Oracle and/or its affiliates. All rights reserved.
*
* $Id$
*/
@@ -73,6 +73,17 @@
#endif /* !HAVE_SYSTEM_INCLUDE_FILES */
+/*
+ * The Windows compiler needs to be told about structures that are available
+ * outside a dll.
+ */
+#if defined(DB_WIN32) && defined(_MSC_VER) && \
+ !defined(DB_CREATE_DLL) && !defined(_LIB)
+#define __DB_IMPORT __declspec(dllimport)
+#else
+#define __DB_IMPORT
+#endif
+
#ifdef DB_WIN32
#include "dbinc/win_db.h"
#endif
@@ -88,22 +99,12 @@
#include "dbinc/queue.h"
#include "dbinc/shqueue.h"
#include "dbinc/perfmon.h"
+#include "dbinc/clock.h"
#if defined(__cplusplus)
extern "C" {
#endif
-/*
- * The Windows compiler needs to be told about structures that are available
- * outside a dll.
- */
-#if defined(DB_WIN32) && defined(_MSC_VER) && \
- !defined(DB_CREATE_DLL) && !defined(_LIB)
-#define __DB_IMPORT __declspec(dllimport)
-#else
-#define __DB_IMPORT
-#endif
-
/*******************************************************
* Forward structure declarations.
*******************************************************/
@@ -366,22 +367,27 @@ typedef struct __fn {
/*
* Structure used for callback message aggregation.
*
- * Display values in XXX_stat_print calls.
+ * DB_MSGBUF_FLUSH displays values in XXX_stat_print calls.
+ * DB_MSGBUF_REP_FLUSH displays replication system messages.
*/
typedef struct __db_msgbuf {
char *buf; /* Heap allocated buffer. */
char *cur; /* Current end of message. */
size_t len; /* Allocated length of buffer. */
+ int flags;
} DB_MSGBUF;
+#define DB_MSGBUF_PREALLOCATED 0x0001
+
#define DB_MSGBUF_INIT(a) do { \
(a)->buf = (a)->cur = NULL; \
- (a)->len = 0; \
+ (a)->len = (a)->flags = 0; \
} while (0)
#define DB_MSGBUF_FLUSH(env, a) do { \
if ((a)->buf != NULL) { \
if ((a)->cur != (a)->buf) \
__db_msg(env, "%s", (a)->buf); \
- __os_free(env, (a)->buf); \
+ if (!F_ISSET((a), DB_MSGBUF_PREALLOCATED)) \
+ __os_free(env, (a)->buf); \
DB_MSGBUF_INIT(a); \
} \
} while (0)
@@ -392,18 +398,14 @@ typedef struct __db_msgbuf {
if (regular_msg) \
DB_MSGBUF_FLUSH(env, a); \
else { \
- __os_free(env, (a)->buf); \
+ if (!F_ISSET((a), DB_MSGBUF_PREALLOCATED)) \
+ __os_free(env, (a)->buf); \
DB_MSGBUF_INIT(a); \
} \
} \
} while (0)
-#define STAT_FMT(msg, fmt, type, v) do { \
- DB_MSGBUF __mb; \
- DB_MSGBUF_INIT(&__mb); \
- __db_msgadd(env, &__mb, fmt, (type)(v)); \
- __db_msgadd(env, &__mb, "\t%s", msg); \
- DB_MSGBUF_FLUSH(env, &__mb); \
-} while (0)
+#define STAT_FMT(msg, fmt, type, v) \
+ __db_msg(env, fmt "\t%s", (type)(v), msg);
#define STAT_HEX(msg, v) \
__db_msg(env, "%#lx\t%s", (u_long)(v), msg)
#define STAT_ISSET(msg, p) \
@@ -441,25 +443,21 @@ typedef struct __db_msgbuf {
*
* Error message IDs are automatically assigned by dist/s_message_id script.
*/
-#ifdef HAVE_LOCALIZATION
-#define _(msg) msg /* Replace with localization function. */
-#else
-#define _(msg) msg
-#endif
-
#ifdef HAVE_STRIPPED_MESSAGES
#define DB_STR_C(msg, fmt) fmt
#else
-#define DB_STR_C(msg, fmt) _(msg)
+#define DB_STR_C(msg, fmt) msg
#endif
-#define DB_MSGID(id) "BDB" id
-
-#define DB_STR(id, msg) DB_MSGID(id) " " DB_STR_C(msg, "")
-
-#define DB_STR_A(id, msg, fmt) DB_MSGID(id) " " DB_STR_C(msg, fmt)
+#ifdef HAVE_LOCALIZATION
+#define _(msg) (msg) /* Replace with localization function. */
+#else
+#define _(msg) msg
+#endif
-#define DB_STR_P(msg) _(msg)
+#define DB_STR(id, msg) _("BDB" id " " DB_STR_C(msg, ""))
+#define DB_STR_A(id, msg, fmt) _("BDB" id " " DB_STR_C(msg, fmt))
+#define DB_STR_P(msg) _(msg)
/*
* There are quite a few places in Berkeley DB where we want to initialize
@@ -542,6 +540,7 @@ typedef struct __db_msgbuf {
/* Type passed to __db_appname(). */
typedef enum {
DB_APP_NONE=0, /* No type (region). */
+ DB_APP_BLOB, /* Blob file. */
DB_APP_DATA, /* Data file. */
DB_APP_LOG, /* Log file. */
DB_APP_META, /* Persistent metadata file. */
@@ -612,8 +611,13 @@ typedef enum {
if (F_ISSET((env), ENV_OPEN_CALLED)) \
ENV_REQUIRES_CONFIG(env, handle, i, flags)
+/*
+ * The ENV_ENTER and ENV_LEAVE macros announce to other threads that
+ * the current thread is entering or leaving the BDB api.
+ */
#define ENV_ENTER_RET(env, ip, ret) do { \
ret = 0; \
+ DISCARD_HISTORY(env); \
PANIC_CHECK_RET(env, ret); \
if (ret == 0) { \
if ((env)->thr_hashtab == NULL) \
@@ -631,6 +635,10 @@ typedef enum {
return (__ret); \
} while (0)
+/*
+ * Publicize the current thread's intention to run failchk. This invokes
+ * DB_ENV->is_alive() in the mutex code, to avoid hanging on dead processes.
+ */
#define FAILCHK_THREAD(env, ip) do { \
if ((ip) != NULL) \
(ip)->dbth_state = THREAD_FAILCHK; \
@@ -638,20 +646,15 @@ typedef enum {
#define ENV_GET_THREAD_INFO(env, ip) ENV_ENTER(env, ip)
-#ifdef DIAGNOSTIC
#define ENV_LEAVE(env, ip) do { \
- if ((ip) != NULL) { \
- DB_ASSERT(env, ((ip)->dbth_state == THREAD_ACTIVE || \
- (ip)->dbth_state == THREAD_FAILCHK)); \
+ if ((ip) != NULL) { \
+ DB_ASSERT((env), (ip)->dbth_state == THREAD_ACTIVE || \
+ (ip)->dbth_state == THREAD_FAILCHK); \
(ip)->dbth_state = THREAD_OUT; \
} \
} while (0)
-#else
-#define ENV_LEAVE(env, ip) do { \
- if ((ip) != NULL) \
- (ip)->dbth_state = THREAD_OUT; \
-} while (0)
-#endif
+
+
#ifdef DIAGNOSTIC
#define CHECK_THREAD(env) do { \
if ((env)->thr_hashtab != NULL) \
@@ -688,6 +691,23 @@ typedef struct __pin_list {
} PIN_LIST;
#define PINMAX 4
+typedef enum {
+ MUTEX_ACTION_UNLOCKED=0,
+ MUTEX_ACTION_INTEND_SHARE, /* Thread is attempting a read-lock. */
+ MUTEX_ACTION_SHARED /* Thread has gotten a read lock. */
+} MUTEX_ACTION;
+
+typedef struct __mutex_state { /* SHARED */
+ db_mutex_t mutex;
+ MUTEX_ACTION action;
+#ifdef DIAGNOSTIC
+ db_timespec when;
+#endif
+} MUTEX_STATE;
+
+#define MUTEX_STATE_MAX 10 /* It only needs enough for shared latches. */
+
+
struct __db_thread_info { /* SHARED */
pid_t dbth_pid;
db_threadid_t dbth_tid;
@@ -707,11 +727,25 @@ struct __db_thread_info { /* SHARED */
u_int16_t dbth_pinmax; /* Number of slots allocated. */
roff_t dbth_pinlist; /* List of pins. */
PIN_LIST dbth_pinarray[PINMAX]; /* Initial array of slots. */
+
+ /*
+ * While thread tracking is active this caches one of the lockers
+ * created by each thread. This locker remains allocated, with an
+ * invalid id, even after the locker id is freed.
+ */
+ roff_t dbth_local_locker;
+ /*
+ * Each latch shared by this thread has an entry here. Exclusive
+ * ownership, for both latches and mutexes, are in the DB_MUTEX.
+ */
+ MUTEX_STATE dbth_latches[MUTEX_STATE_MAX];
#ifdef DIAGNOSTIC
roff_t dbth_locker; /* Current locker for this thread. */
u_int32_t dbth_check_off; /* Count of number of LOCK_OFF calls. */
#endif
+ db_timespec dbth_failtime; /* Time when its crash was detected. */
};
+
#ifdef DIAGNOSTIC
#define LOCK_CHECK_OFF(ip) if ((ip) != NULL) \
(ip)->dbth_check_off++
@@ -729,7 +763,7 @@ struct __db_thread_info { /* SHARED */
#define LOCK_CHECK(dbc, pgno, mode) NOP_STATEMENT
#endif
-typedef struct __env_thread_info {
+typedef struct __env_thread_info { /* SHARED */
u_int32_t thr_count;
u_int32_t thr_init;
u_int32_t thr_max;
@@ -803,6 +837,11 @@ struct __env {
#define ENV_DEF_DATA_LEN 100
u_int32_t data_len; /* Data length in __db_prbytes. */
+ /* Registered processes */
+ size_t num_active_pids; /* number of entries in active_pids */
+ size_t size_active_pids; /* allocated size of active_pids */
+ pid_t *active_pids; /* array active pids */
+
/* Thread tracking */
u_int32_t thr_nbucket; /* Number of hash buckets */
DB_HASHTAB *thr_hashtab; /* Hash table of DB_THREAD_INFO */
@@ -866,6 +905,7 @@ struct __env {
#define DB_TEST_PREOPEN 10 /* before __os_open */
#define DB_TEST_REPMGR_PERM 11 /* repmgr perm/archiving tests */
#define DB_TEST_SUBDB_LOCKS 12 /* subdb locking tests */
+#define DB_TEST_REPMGR_HEARTBEAT 13 /* repmgr stop sending heartbeats */
int test_abort; /* Abort value for testing */
int test_check; /* Checkpoint value for testing */
int test_copy; /* Copy value for testing */
@@ -881,7 +921,9 @@ struct __env {
#define ENV_REF_COUNTED 0x00000100 /* Region references this handle */
#define ENV_SYSTEM_MEM 0x00000200 /* DB_SYSTEM_MEM set */
#define ENV_THREAD 0x00000400 /* DB_THREAD set */
-#define ENV_FORCE_TXN_BULK 0x00000800 /* Txns use bulk mode-for testing */
+#define ENV_FORCE_TXN_BULK 0x00000800 /* Txns use bulk mode-for testing */
+#define ENV_REMEMBER_PANIC 0x00001000 /* Panic was on during cleanup. */
+#define ENV_FORCESYNCENV 0x00002000 /* Force msync on closing. */
u_int32_t flags;
};
@@ -1106,7 +1148,6 @@ typedef struct __dbpginfo {
@db_int_def@
#include "dbinc/globals.h"
-#include "dbinc/clock.h"
#include "dbinc/debug.h"
#include "dbinc/region.h"
#include "dbinc_auto/env_ext.h"
@@ -1118,6 +1159,7 @@ typedef struct __dbpginfo {
#include "dbinc/os.h"
#include "dbinc_auto/clib_ext.h"
#include "dbinc_auto/common_ext.h"
+#include "dbinc_auto/blob_ext.h"
/*******************************************************
* Remaining Log.