~ignacio-nin/galera/galera-2.x

« back to all changes in this revision

Viewing changes to galera/src/replicator_smm.cpp

  • Committer: Alex Yurchenko
  • Date: 2012-01-28 03:47:04 UTC
  • mfrom: (87.1.20 1.x)
  • Revision ID: ayurchen@void-20120128034704-rdxeaginj8g3fc30
References lp:907071 - synced with SVN r2697

Show diffs side-by-side

added added

removed removed

Lines of Context:
182
182
    uuid_               (WSREP_UUID_UNDEFINED),
183
183
    state_uuid_         (WSREP_UUID_UNDEFINED),
184
184
    state_uuid_str_     (),
185
 
    state_seqno_        (-1),
 
185
    cc_seqno_           (-1),
186
186
    app_ctx_            (args->app_ctx),
187
187
    view_cb_            (args->view_handler_cb),
188
188
    apply_cb_           (args->apply_cb),
1076
1076
 
1077
1077
    if (co_mode_ != CommitOrder::BYPASS) commit_monitor_.drain(upto);
1078
1078
 
1079
 
    wsrep_seqno_t const group_seqno(view_info.seqno);
1080
 
    const wsrep_uuid_t& group_uuid(view_info.uuid);
1081
 
 
1082
1079
    if (view_info.my_idx >= 0)
1083
1080
    {
1084
1081
        uuid_ = view_info.members[view_info.my_idx].id;
1085
1082
    }
1086
1083
 
1087
 
    bool st_required(view_info.state_gap);
 
1084
    bool const          st_required(state_transfer_required(view_info));
 
1085
    wsrep_seqno_t const group_seqno(view_info.seqno);
 
1086
    const wsrep_uuid_t& group_uuid (view_info.uuid);
1088
1087
 
1089
1088
    if (st_required)
1090
1089
    {
1091
 
        assert(view_info.view >= 0);
 
1090
        log_info << "State transfer required: "
 
1091
                 << "\n\tGroup state: " << group_uuid << ":" << group_seqno
 
1092
                 << "\n\tLocal state: " << state_uuid_<< ":"
 
1093
                 << apply_monitor_.last_left();
1092
1094
 
1093
 
        if (state_uuid_ == group_uuid)
1094
 
        {
1095
 
            // common history
1096
 
            if (state_() >= S_JOINING) /* See #442 - S_JOINING should be
1097
 
                                          a valid state here */
1098
 
            {
1099
 
                st_required = (apply_monitor_.last_left() < group_seqno);
1100
 
            }
1101
 
            else
1102
 
            {
1103
 
                st_required = (apply_monitor_.last_left() != group_seqno);
1104
 
            }
1105
 
        }
 
1095
        if (S_CONNECTED != state_()) state_.shift_to(S_CONNECTED);
1106
1096
    }
1107
1097
 
1108
 
    if (st_required && S_CONNECTED != state_()) state_.shift_to(S_CONNECTED);
1109
 
 
1110
1098
    void*   app_req(0);
1111
1099
    ssize_t app_req_len(0);
1112
1100
 
1115
1103
 
1116
1104
    if (app_req_len < 0)
1117
1105
    {
1118
 
        log_fatal << "View callback failed: " << -app_req_len << " ("
1119
 
                  << strerror(-app_req_len) << "). This is unrecoverable, "
1120
 
                  << "restart required.";
1121
 
        abort();
 
1106
        gcs_.close();
 
1107
        gu_throw_fatal << "View callback failed: " << -app_req_len << " ("
 
1108
                       << strerror(-app_req_len) << "). This is unrecoverable, "
 
1109
                       << "restart required.";
 
1110
    }
 
1111
    else if (st_required && 0 == app_req_len && state_uuid_ != group_uuid)
 
1112
    {
 
1113
        gcs_.close();
 
1114
        gu_throw_fatal << "Local state UUID " << state_uuid_
 
1115
                       << " is different from group state UUID " << group_uuid
 
1116
                       << ", and SST request is null: restart required.";
1122
1117
    }
1123
1118
 
1124
1119
    if (view_info.view >= 0) // Primary configuration
1128
1123
        // we have to reset cert initial position here, SST does not contain
1129
1124
        // cert index yet (see #197).
1130
1125
        cert_.assign_initial_position(group_seqno, trx_proto_ver_);
 
1126
 
1131
1127
        // record state seqno, needed for IST on DONOR
1132
 
        state_seqno_ = group_seqno;
 
1128
        cc_seqno_ = group_seqno;
1133
1129
 
1134
1130
        bool const app_wants_st(app_wants_state_transfer(app_req, app_req_len));
1135
1131
 
1408
1404
    }
1409
1405
 
1410
1406
    update_state_uuid (uuid);
1411
 
    state_seqno_ = seqno;
 
1407
    cc_seqno_ = seqno; // is it needed here?
1412
1408
    apply_monitor_.set_initial_position(seqno);
1413
1409
    if (co_mode_ != CommitOrder::BYPASS) commit_monitor_.set_initial_position(seqno);
1414
1410
    cert_.assign_initial_position(seqno, trx_proto_ver_);
1575
1571
}
1576
1572
 
1577
1573
void
1578
 
galera::ReplicatorSMM::abort() throw() /* aborts the program in a clean way */
 
1574
galera::ReplicatorSMM::abort() throw()
1579
1575
{
1580
1576
    gcs_.close();
1581
1577
    gu_abort();