1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems, Inc.
5
* Copyright (C) 2010 Jay Pipes <jaypipes@gmail.com>
4
* Copyright (C) 2008 Sun Microsystems
5
* Copyright (c) 2010 Jay Pipes <jaypipes@gmail.com>
7
7
* This program is free software; you can redistribute it and/or modify
8
8
* it under the terms of the GNU General Public License as published by
35
35
#include <algorithm>
36
36
#include <functional>
44
static std::vector<XaResourceManager *> xa_resource_managers;
46
static vector<XaResourceManager *> xa_resource_managers;
46
48
int XaResourceManager::commitOrRollbackXID(XID *xid, bool commit)
48
std::vector<int> results;
51
53
transform(xa_resource_managers.begin(), xa_resource_managers.end(), results.begin(),
52
std::bind2nd(std::mem_fun(&XaResourceManager::xaCommitXid), xid));
54
bind2nd(mem_fun(&XaResourceManager::xaCommitXid), xid));
54
56
transform(xa_resource_managers.begin(), xa_resource_managers.end(), results.begin(),
55
std::bind2nd(std::mem_fun(&XaResourceManager::xaRollbackXid), xid));
57
bind2nd(mem_fun(&XaResourceManager::xaRollbackXid), xid));
57
if (std::find_if(results.begin(), results.end(), std::bind2nd(std::equal_to<int>(),0)) == results.end())
59
if (find_if(results.begin(), results.end(), bind2nd(equal_to<int>(),0))
76
78
in this case commit_list.size()==0, tc_heuristic_recover == 0
77
79
there should be no prepared transactions in this case.
79
class XaRecover : std::unary_function<XaResourceManager *, void>
81
class XaRecover : unary_function<XaResourceManager *, void>
82
84
int trans_len, found_foreign_xids, found_my_xids;
112
114
while ((got= resource_manager->xaRecover(trans_list, trans_len)) > 0 )
114
errmsg_printf(error::INFO,
116
errmsg_printf(ERRMSG_LVL_INFO,
115
117
_("Found %d prepared transaction(s) in resource manager."),
117
119
for (int i=0; i < got; i ++)
177
errmsg_printf(error::ERROR, ER(ER_OUTOFMEMORY), trans_len*sizeof(XID));
179
errmsg_printf(ERRMSG_LVL_ERROR, ER(ER_OUTOFMEMORY), trans_len*sizeof(XID));
181
183
if (commit_list.size())
182
errmsg_printf(error::INFO, _("Starting crash recovery..."));
184
errmsg_printf(ERRMSG_LVL_INFO, _("Starting crash recovery..."));
184
186
XaRecover recover_func(trans_list, trans_len, commit_list, dry_run);
185
std::for_each(xa_resource_managers.begin(),
186
xa_resource_managers.end(),
187
for_each(xa_resource_managers.begin(),
188
xa_resource_managers.end(),
188
190
free(trans_list);
190
192
if (recover_func.getForeignXIDs())
191
errmsg_printf(error::WARN,
193
errmsg_printf(ERRMSG_LVL_WARN,
192
194
_("Found %d prepared XA transactions"),
193
195
recover_func.getForeignXIDs());
195
196
if (dry_run && recover_func.getMyXIDs())
197
errmsg_printf(error::ERROR,
198
errmsg_printf(ERRMSG_LVL_ERROR,
198
199
_("Found %d prepared transactions! It means that drizzled "
199
200
"was not shut down properly last time and critical "
200
201
"recovery information (last binlog or %s file) was "
204
205
recover_func.getMyXIDs(), opt_tc_log_file);
208
208
if (commit_list.size())
209
errmsg_printf(error::INFO, _("Crash recovery finished."));
209
errmsg_printf(ERRMSG_LVL_INFO, _("Crash recovery finished."));