diff --git a/src/GUI/QtLauncher.cxx b/src/GUI/QtLauncher.cxx index a9bbe10b0..baf5de35f 100644 --- a/src/GUI/QtLauncher.cxx +++ b/src/GUI/QtLauncher.cxx @@ -218,14 +218,18 @@ private: return; flightgear::PolyLineList::const_iterator begin = m_parsedLines.begin() + m_lineInsertCount; - unsigned int numToAdd = std::min<unsigned int>(1000U, static_cast<unsigned int>(m_parsedLines.size()) - m_lineInsertCount); + + // add lines in batches of 100; this is a tradeoff to ensure we don't lock + // the database for too long. (Which triggers SQLITE_BUSY) + const int lineInsertBatchSize = 100U; + unsigned int numToAdd = std::min<unsigned int>(100U, static_cast<unsigned int>(m_parsedLines.size()) - m_lineInsertCount); flightgear::PolyLineList::const_iterator end = begin + numToAdd; flightgear::PolyLine::bulkAddToSpatialIndex(begin, end); if (end == m_parsedLines.end()) { deleteLater(); // commit suicide } else { - m_lineInsertCount += 1000; + m_lineInsertCount += lineInsertBatchSize; QTimer::singleShot(50, this, SLOT(onFinished())); } } diff --git a/src/Navaids/NavDataCache.cxx b/src/Navaids/NavDataCache.cxx index 1e28d691e..e5f1d4f63 100644 --- a/src/Navaids/NavDataCache.cxx +++ b/src/Navaids/NavDataCache.cxx @@ -458,6 +458,8 @@ public: { int retries = 0; int result; + int retryMSec = 10; + while (retries < MAX_RETRIES) { result = sqlite3_step(stmt); if (result == SQLITE_ROW) { @@ -473,7 +475,8 @@ public: } SG_LOG(SG_NAVCACHE, SG_ALERT, "NavCache contention on select, will retry:" << retries); - SGTimeStamp::sleepForMSec(++retries * 10); + SGTimeStamp::sleepForMSec(retryMSec); + retryMSec *= 2; // double the back-off time, each time } // of retry loop for DB locked if (retries >= MAX_RETRIES) {