~ubuntu-branches/ubuntu/edgy/rpm/edgy

« back to all changes in this revision

Viewing changes to db/include/txn.h

  • Committer: Bazaar Package Importer
  • Author(s): Joey Hess
  • Date: 2002-01-22 20:56:57 UTC
  • Revision ID: james.westby@ubuntu.com-20020122205657-l74j50mr9z8ofcl5
Tags: upstream-4.0.3
ImportĀ upstreamĀ versionĀ 4.0.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*-
 
2
 * See the file LICENSE for redistribution information.
 
3
 *
 
4
 * Copyright (c) 1996-2001
 
5
 *      Sleepycat Software.  All rights reserved.
 
6
 *
 
7
 * $Id: txn.h,v 11.25 2001/07/10 20:06:53 sue Exp $
 
8
 */
 
9
 
 
10
#ifndef _TXN_H_
 
11
#define _TXN_H_
 
12
 
 
13
#include "xa.h"
 
14
 
 
15
struct __db_txnmgr;     typedef struct __db_txnmgr DB_TXNMGR;
 
16
struct __db_txnregion;  typedef struct __db_txnregion DB_TXNREGION;
 
17
 
 
18
/*
 
19
 * !!!
 
20
 * TXN_MINIMUM = (DB_LOCK_MAXID + 1) but this makes compilers complain.
 
21
 */
 
22
#define TXN_MINIMUM     0x80000000
 
23
#define TXN_INVALID     0xffffffff      /* Maximum number of txn ids. */
 
24
#define TXN_INVALID_ID  0               /* Invalid transaction ID. */
 
25
 
 
26
#define DEF_MAX_TXNS    20              /* Default max transactions. */
 
27
 
 
28
/* The structure allocated for every transaction. */
 
29
struct __db_txn {
 
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 */
 
39
 
 
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. */
 
47
        u_int32_t       flags;
 
48
};
 
49
 
 
50
/*
 
51
 * Internal data maintained in shared memory for each transaction.
 
52
 */
 
53
 
 
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. */
 
60
 
 
61
#define TXN_RUNNING             1
 
62
#define TXN_ABORTED             2
 
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 */
 
69
 
 
70
        SH_TAILQ_ENTRY  links;          /* free/active list */
 
71
 
 
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 */
 
79
 
 
80
        /*
 
81
         * XID (xid_t) structure: because these fields are logged, the
 
82
         * sizes have to be explicit.
 
83
         */
 
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 */
 
88
} TXN_DETAIL;
 
89
 
 
90
/*
 
91
 * DB_TXNMGR --
 
92
 *      The transaction manager encapsulates the transaction system.
 
93
 */
 
94
struct __db_txnmgr {
 
95
/*
 
96
 * These fields need to be protected for multi-threaded support.
 
97
 *
 
98
 * !!!
 
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.
 
102
 */
 
103
        MUTEX           *mutexp;        /* Lock list of active transactions
 
104
                                         * (including the content of each
 
105
                                         * TXN_DETAIL structure on the list).
 
106
                                         */
 
107
                                        /* List of active transactions. */
 
108
        TAILQ_HEAD(_chain, __db_txn)    txn_chain;
 
109
        u_int32_t        n_discards;    /* Number of txns discarded. */
 
110
 
 
111
/* These fields are never updated after creation, and so not protected. */
 
112
        DB_ENV          *dbenv;         /* Environment. */
 
113
        REGINFO          reginfo;       /* Region information. */
 
114
};
 
115
 
 
116
/*
 
117
 * DB_TXNREGION --
 
118
 *      The primary transaction data structure in the shared memory region.
 
119
 */
 
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 */
 
129
        u_int32_t       flags;
 
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)
 
140
 
 
141
        roff_t          maint_off;      /* offset of region maintenance info */
 
142
#endif
 
143
};
 
144
 
 
145
/*
 
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.
 
149
 */
 
150
#define TXN_OK          0
 
151
#define TXN_COMMIT      1
 
152
#define TXN_PREPARE     2
 
153
#define TXN_ABORT       3
 
154
#define TXN_NOTFOUND    4
 
155
#define TXN_IGNORE      5
 
156
 
 
157
#include "txn_auto.h"
 
158
#include "txn_ext.h"
 
159
 
 
160
#include "xa_ext.h"
 
161
#endif /* !_TXN_H_ */