mirror of
https://github.com/XRPLF/clio.git
synced 2025-11-20 19:56:00 +00:00
bug fix
This commit is contained in:
@@ -209,7 +209,6 @@ BackendIndexer::finish(uint32_t ledgerSequence, BackendInterface const& backend)
|
||||
BOOST_LOG_TRIVIAL(debug)
|
||||
<< __func__
|
||||
<< " starting. sequence = " << std::to_string(ledgerSequence);
|
||||
bool isFirst = false;
|
||||
auto keyIndex = getKeyIndexOfSeq(ledgerSequence);
|
||||
if (isFirst_)
|
||||
{
|
||||
|
||||
@@ -7,6 +7,7 @@ template <class T, class F>
|
||||
void
|
||||
processAsyncWriteResponse(T& requestParams, CassFuture* fut, F func)
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(debug) << __func__ << " Processing async write response";
|
||||
CassandraBackend const& backend = *requestParams.backend;
|
||||
auto rc = cass_future_error_code(fut);
|
||||
if (rc != CASS_OK)
|
||||
@@ -39,6 +40,7 @@ template <class T>
|
||||
void
|
||||
processAsyncWrite(CassFuture* fut, void* cbData)
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(debug) << __func__ << " processing async write";
|
||||
T& requestParams = *static_cast<T*>(cbData);
|
||||
// TODO don't pass in func
|
||||
processAsyncWriteResponse(requestParams, fut, requestParams.retry);
|
||||
@@ -56,6 +58,7 @@ struct WriteCallbackData
|
||||
WriteCallbackData(CassandraBackend const* b, T&& d, B bind)
|
||||
: backend(b), data(std::move(d))
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(debug) << "Making WriteCallbackData";
|
||||
retry = [bind, this](auto& params, bool isRetry) {
|
||||
auto statement = bind(params);
|
||||
backend->executeAsyncWrite(
|
||||
@@ -69,7 +72,10 @@ struct WriteCallbackData
|
||||
virtual void
|
||||
start()
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(debug) << "Starting";
|
||||
BOOST_LOG_TRIVIAL(debug) << "address is " << this;
|
||||
retry(*this, false);
|
||||
BOOST_LOG_TRIVIAL(debug) << "Started";
|
||||
}
|
||||
|
||||
virtual void
|
||||
@@ -82,6 +88,7 @@ struct WriteCallbackData
|
||||
}
|
||||
virtual ~WriteCallbackData()
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(debug) << __func__;
|
||||
}
|
||||
};
|
||||
template <class T, class B>
|
||||
@@ -342,8 +349,11 @@ CassandraBackend::fetchTransactions(
|
||||
statement.bindBytes(hashes[i]);
|
||||
cbs.push_back(std::make_shared<ReadCallbackData>(
|
||||
numOutstanding, mtx, cv, [i, &results](auto& result) {
|
||||
results[i] = {
|
||||
result.getBytes(), result.getBytes(), result.getUInt32()};
|
||||
if (result.hasResult())
|
||||
results[i] = {
|
||||
result.getBytes(),
|
||||
result.getBytes(),
|
||||
result.getUInt32()};
|
||||
}));
|
||||
executeAsyncRead(statement, processAsyncRead, *cbs[i]);
|
||||
}
|
||||
@@ -480,7 +490,8 @@ CassandraBackend::fetchLedgerObjects(
|
||||
{
|
||||
cbs.push_back(std::make_shared<ReadCallbackData>(
|
||||
numOutstanding, mtx, cv, [i, &results](auto& result) {
|
||||
results[i] = result.getBytes();
|
||||
if (result.hasResult())
|
||||
results[i] = result.getBytes();
|
||||
}));
|
||||
CassandraStatement statement{selectObject_};
|
||||
statement.bindBytes(keys[i]);
|
||||
@@ -515,7 +526,7 @@ CassandraBackend::writeKeys(
|
||||
statement.bindBytes(key);
|
||||
return statement;
|
||||
};
|
||||
std::atomic_int numOutstanding = keys.size();
|
||||
std::atomic_int numOutstanding = 0;
|
||||
std::condition_variable cv;
|
||||
std::mutex mtx;
|
||||
std::vector<std::shared_ptr<BulkWriteCallbackData<
|
||||
|
||||
@@ -108,6 +108,15 @@ public:
|
||||
cass_statement_set_consistency(statement_, CASS_CONSISTENCY_QUORUM);
|
||||
}
|
||||
|
||||
CassandraStatement(CassandraStatement&& other)
|
||||
{
|
||||
statement_ = other.statement_;
|
||||
other.statement_ = nullptr;
|
||||
curBindingIndex_ = other.curBindingIndex_;
|
||||
other.curBindingIndex_ = 0;
|
||||
}
|
||||
CassandraStatement(CassandraStatement const& other) = delete;
|
||||
|
||||
CassStatement*
|
||||
get() const
|
||||
{
|
||||
@@ -950,11 +959,15 @@ public:
|
||||
T callback,
|
||||
S& callbackData) const
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(debug) << "Executing";
|
||||
|
||||
BOOST_LOG_TRIVIAL(debug) << "address = " << &callbackData;
|
||||
CassFuture* fut = cass_session_execute(session_.get(), statement.get());
|
||||
|
||||
cass_future_set_callback(
|
||||
fut, callback, static_cast<void*>(&callbackData));
|
||||
cass_future_free(fut);
|
||||
BOOST_LOG_TRIVIAL(debug) << "Submitted callback";
|
||||
}
|
||||
template <class T, class S>
|
||||
void
|
||||
|
||||
@@ -114,10 +114,13 @@ ReportingETL::loadInitialLedger(uint32_t startingSequence)
|
||||
<< "Deserialized ledger header. " << detail::toString(lgrInfo);
|
||||
|
||||
backend_->startWrites();
|
||||
BOOST_LOG_TRIVIAL(debug) << __func__ << " started writes";
|
||||
backend_->writeLedger(
|
||||
lgrInfo, std::move(*ledgerData->mutable_ledger_header()), true);
|
||||
BOOST_LOG_TRIVIAL(debug) << __func__ << " wrote ledger";
|
||||
std::vector<AccountTransactionsData> accountTxData =
|
||||
insertTransactions(lgrInfo, *ledgerData);
|
||||
BOOST_LOG_TRIVIAL(debug) << __func__ << " inserted txns";
|
||||
|
||||
auto start = std::chrono::system_clock::now();
|
||||
|
||||
@@ -126,6 +129,7 @@ ReportingETL::loadInitialLedger(uint32_t startingSequence)
|
||||
// consumes from the queue and inserts the data into the Ledger object.
|
||||
// Once the below call returns, all data has been pushed into the queue
|
||||
loadBalancer_->loadInitialLedger(startingSequence);
|
||||
BOOST_LOG_TRIVIAL(debug) << __func__ << " loaded initial ledger";
|
||||
|
||||
if (!stopping_)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user