2
* See the file LICENSE for redistribution information.
4
* Copyright (c) 1996-2001
5
* Sleepycat Software. All rights reserved.
7
* $Id: txn.h,v 11.25 2001/07/10 20:06:53 sue Exp $
15
struct __db_txnmgr; typedef struct __db_txnmgr DB_TXNMGR;
16
struct __db_txnregion; typedef struct __db_txnregion DB_TXNREGION;
20
* TXN_MINIMUM = (DB_LOCK_MAXID + 1) but this makes compilers complain.
22
#define TXN_MINIMUM 0x80000000
23
#define TXN_INVALID 0xffffffff /* Maximum number of txn ids. */
24
#define TXN_INVALID_ID 0 /* Invalid transaction ID. */
26
#define DEF_MAX_TXNS 20 /* Default max transactions. */
28
/* The structure allocated for every transaction. */
30
DB_TXNMGR *mgrp; /* Pointer to transaction manager. */
31
DB_TXN *parent; /* Pointer to transaction's parent. */
32
DB_LSN last_lsn; /* Lsn of last log write. */
33
u_int32_t txnid; /* Unique transaction id. */
34
roff_t off; /* Detail structure within region. */
35
TAILQ_ENTRY(__db_txn) links; /* Links transactions off manager. */
36
TAILQ_HEAD(__kids, __db_txn) kids; /* Child transactions. */
37
TAILQ_ENTRY(__db_txn) klinks; /* Links child transactions. */
38
u_int32_t cursors; /* Number of cursors open for txn */
40
#define TXN_CHILDCOMMIT 0x01 /* Transaction that has committed. */
41
#define TXN_COMPENSATE 0x02 /* Compensating transaction. */
42
#define TXN_DIRTY_READ 0x04 /* Transaction does dirty reads. */
43
#define TXN_MALLOC 0x08 /* Structure allocated by TXN system. */
44
#define TXN_NOSYNC 0x10 /* Do not sync on prepare and commit. */
45
#define TXN_NOWAIT 0x20 /* Do not wait on locks. */
46
#define TXN_SYNC 0x40 /* Sync on prepare and commit. */
51
* Internal data maintained in shared memory for each transaction.
54
typedef struct __txn_detail {
55
u_int32_t txnid; /* current transaction id
56
used to link free list also */
57
DB_LSN last_lsn; /* last lsn written for this txn */
58
DB_LSN begin_lsn; /* lsn of begin record */
59
roff_t parent; /* Offset of transaction's parent. */
63
#define TXN_PREPARED 3
64
#define TXN_COMMITTED 4
65
u_int32_t status; /* status of the transaction */
66
#define TXN_COLLECTED 0x1
67
#define TXN_RESTORED 0x2
68
u_int32_t flags; /* collected during txn_recover */
70
SH_TAILQ_ENTRY links; /* free/active list */
72
#define TXN_XA_ABORTED 1
73
#define TXN_XA_DEADLOCKED 2
74
#define TXN_XA_ENDED 3
75
#define TXN_XA_PREPARED 4
76
#define TXN_XA_STARTED 5
77
#define TXN_XA_SUSPENDED 6
78
u_int32_t xa_status; /* XA status */
81
* XID (xid_t) structure: because these fields are logged, the
82
* sizes have to be explicit.
84
u_int8_t xid[XIDDATASIZE]; /* XA global transaction id */
85
u_int32_t bqual; /* bqual_length from XID */
86
u_int32_t gtrid; /* gtrid_length from XID */
87
int32_t format; /* XA format */
92
* The transaction manager encapsulates the transaction system.
96
* These fields need to be protected for multi-threaded support.
99
* As this structure is allocated in per-process memory, the mutex may need
100
* to be stored elsewhere on architectures unable to support mutexes in heap
101
* memory, e.g., HP/UX 9.
103
MUTEX *mutexp; /* Lock list of active transactions
104
* (including the content of each
105
* TXN_DETAIL structure on the list).
107
/* List of active transactions. */
108
TAILQ_HEAD(_chain, __db_txn) txn_chain;
109
u_int32_t n_discards; /* Number of txns discarded. */
111
/* These fields are never updated after creation, and so not protected. */
112
DB_ENV *dbenv; /* Environment. */
113
REGINFO reginfo; /* Region information. */
118
* The primary transaction data structure in the shared memory region.
120
struct __db_txnregion {
121
u_int32_t maxtxns; /* maximum number of active TXNs */
122
u_int32_t last_txnid; /* last transaction id given out */
123
DB_LSN pending_ckp; /* last checkpoint did not finish */
124
DB_LSN last_ckp; /* lsn of the last checkpoint */
125
time_t time_ckp; /* time of last checkpoint */
126
u_int32_t logtype; /* type of logging */
127
u_int32_t locktype; /* lock type */
128
#define TXN_IN_RECOVERY 0x01 /* environment is being recovered */
130
u_int32_t naborts; /* number of aborted TXNs */
131
u_int32_t ncommits; /* number of committed TXNs */
132
u_int32_t nbegins; /* number of begun TXNs */
133
u_int32_t nactive; /* number of active TXNs */
134
u_int32_t nrestores; /* number of restored TXNs */
135
u_int32_t maxnactive; /* maximum number of active TXNs */
136
/* active TXN list */
137
SH_TAILQ_HEAD(__active) active_txn;
138
#ifdef MUTEX_SYSTEM_RESOURCES
139
#define TXN_MAINT_SIZE (sizeof(roff_t) * DB_MAX_HANDLES)
141
roff_t maint_off; /* offset of region maintenance info */
146
* Log record types. Note that these are *not* alphabetical. This is
147
* intentional so that we don't change the meaning of values between
148
* software upgrades. IGNORE, NOTFOUND and OK are used in the txnlist functions.
152
#define TXN_PREPARE 2
154
#define TXN_NOTFOUND 4
157
#include "txn_auto.h"
161
#endif /* !_TXN_H_ */