~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/xa_resource_manager.cc

  • Committer: lbieber
  • Date: 2010-08-24 15:18:42 UTC
  • mfrom: (1728.2.1 staging)
  • Revision ID: lbieber@orisndriz03-20100824151842-atg58mkkqclizgqx
Merge Monty -  Removed a HASH in xa_resource_manager
Merge Patrick -  Final update of embedded_innodb tests - fix for hudson build

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
#include "config.h"
22
22
 
23
 
#include "drizzled/my_hash.h"
24
23
#include "drizzled/cached_directory.h"
25
24
 
26
25
#include <drizzled/definitions.h>
69
68
  @note
70
69
    there are three modes of operation:
71
70
    - automatic recover after a crash
72
 
    in this case commit_list != 0, tc_heuristic_recover==0
 
71
    in this case commit_list.size() != 0, tc_heuristic_recover==0
73
72
    all xids from commit_list are committed, others are rolled back
74
73
    - manual (heuristic) recover
75
 
    in this case commit_list==0, tc_heuristic_recover != 0
 
74
    in this case commit_list.size()==0, tc_heuristic_recover != 0
76
75
    DBA has explicitly specified that all prepared transactions should
77
76
    be committed (or rolled back).
78
 
    - no recovery (MySQL did not detect a crash)
79
 
    in this case commit_list==0, tc_heuristic_recover == 0
 
77
    - no recovery (Drizzle did not detect a crash)
 
78
    in this case commit_list.size()==0, tc_heuristic_recover == 0
80
79
    there should be no prepared transactions in this case.
81
80
*/
82
81
class XaRecover : unary_function<XaResourceManager *, void>
83
82
{
 
83
private:
84
84
  int trans_len, found_foreign_xids, found_my_xids;
85
85
  bool result;
86
86
  XID *trans_list;
87
 
  HASH *commit_list;
 
87
  const XaResourceManager::commit_list_set &commit_list;
88
88
  bool dry_run;
89
89
public:
90
90
  XaRecover(XID *trans_list_arg, int trans_len_arg,
91
 
            HASH *commit_list_arg, bool dry_run_arg) 
 
91
            const XaResourceManager::commit_list_set& commit_list_arg,
 
92
            bool dry_run_arg) 
92
93
    : trans_len(trans_len_arg), found_foreign_xids(0), found_my_xids(0),
93
94
      result(false),
94
95
      trans_list(trans_list_arg), commit_list(commit_list_arg),
130
131
          continue;
131
132
        }
132
133
        // recovery mode
133
 
        if (commit_list ?
134
 
            hash_search(commit_list, (unsigned char *)&x, sizeof(x)) != 0 :
 
134
        if (commit_list.size() ?
 
135
            commit_list.find(x) != commit_list.end() :
135
136
            tc_heuristic_recover == TC_HEURISTIC_RECOVER_COMMIT)
136
137
        {
137
138
          resource_manager->xaCommitXid(trans_list+i);
147
148
  }
148
149
};
149
150
 
150
 
int XaResourceManager::recoverAllXids(HASH *commit_list)
 
151
int XaResourceManager::recoverAllXids()
 
152
{
 
153
  const XaResourceManager::commit_list_set empty_commit_set;
 
154
  return recoverAllXids(empty_commit_set);
 
155
}
 
156
 
 
157
int XaResourceManager::recoverAllXids(const XaResourceManager::commit_list_set &commit_list)
151
158
{
152
159
  XID *trans_list= NULL;
153
160
  int trans_len= 0;
154
161
 
155
 
  bool dry_run= (commit_list==0 && tc_heuristic_recover==0);
 
162
  bool dry_run= (commit_list.size() == 0 && tc_heuristic_recover==0);
156
163
 
157
164
  /* commit_list and tc_heuristic_recover cannot be set both */
158
 
  assert(commit_list==0 || tc_heuristic_recover==0);
 
165
  assert(commit_list.size() == 0 || tc_heuristic_recover == 0);
159
166
 
160
167
  if (xa_resource_managers.size() <= 1)
161
168
    return 0;
173
180
    return(1);
174
181
  }
175
182
 
176
 
  if (commit_list)
 
183
  if (commit_list.size())
177
184
    errmsg_printf(ERRMSG_LVL_INFO, _("Starting crash recovery..."));
178
185
 
179
186
  XaRecover recover_func(trans_list, trans_len, commit_list, dry_run);
198
205
                    recover_func.getMyXIDs(), opt_tc_log_file);
199
206
    return(1);
200
207
  }
201
 
  if (commit_list)
 
208
  if (commit_list.size())
202
209
    errmsg_printf(ERRMSG_LVL_INFO, _("Crash recovery finished."));
203
210
  return(0);
204
211
}