Revision 0c9272b6

View differences:

src/raft/FedReplicaManager.cc
102 102
        rc = last_index;
103 103

  
104 104
        pthread_mutex_unlock(&mutex);
105

  
106 105
        return rc;
107 106
    }
108 107

  
109
    if ( insert_log_record(last_index + 1, sql) != 0 )
108
    std::ostringstream oss;
109

  
110
    char * sql_db = logdb->escape_str(sql.c_str());
111

  
112
    if ( sql_db == 0 )
110 113
    {
111 114
        pthread_mutex_unlock(&mutex);
112 115
        return -1;
113 116
    }
114 117

  
115
    last_index++;
118
    oss << "BEGIN;\n" 
119
        << "REPLACE INTO " << table << " ("<< db_names <<") VALUES "
120
        << "(" << last_index + 1 << ",'" << sql_db << "');\n"
121
        << sql << ";\n"
122
        << "END;";
116 123

  
117
    std::ostringstream oss(sql);
124
    if ( logdb->exec_wr(oss) != 0 )
125
    {
126
        pthread_mutex_unlock(&mutex);
127
        return -1;
128
    }
118 129

  
119
    logdb->exec_wr(oss);
130
    last_index++;
120 131

  
121 132
    pthread_mutex_unlock(&mutex);
122 133

  
......
496 507
        {
497 508
            zs->next = last_zone + 1;
498 509
        }
499
    }
500 510

  
501
    ReplicaManager::replicate(zone_id);
511
        if ( last_index >= zs->next )
512
        {
513
            ReplicaManager::replicate(zone_id);
514
        }
515
    }
502 516

  
503 517
    pthread_mutex_unlock(&mutex);
504 518
}

Also available in: Unified diff