prevent death of server if we're waiting on a save to finish but still warn about it; only lock at the top of saveCompleted

This commit is contained in:
DarthArgus
2016-12-09 21:02:46 +00:00
parent 802af495dc
commit 87443dd17e
3 changed files with 12 additions and 19 deletions
@@ -56,7 +56,7 @@ void ConfigServerDatabase::install(void)
KEY_INT (taskManagerPort, 60001);
KEY_INT (expectedDBVersion, 270);
KEY_BOOL (correctDBVersionRequired,true);
KEY_INT (saveFrequencyLimit,5);
KEY_INT (saveFrequencyLimit,1);
KEY_STRING (schemaOwner, "");
KEY_STRING (goldSchemaOwner, "");
KEY_FLOAT (uniqueMessageCacheTimeSec, 30.0f);
@@ -261,8 +261,7 @@ void Persister::onFrameBarrierReached()
}
// Check for whether it is time to save
FATAL(m_timeSinceLastSave > ConfigServerDatabase::getMaxTimewarp(),("Save was not completed within %i seconds. Shutting down to avoid a longer timewarp.\n",ConfigServerDatabase::getMaxTimewarp()));
WARNING(m_timeSinceLastSave > ConfigServerDatabase::getMaxTimewarp(),("Save was not completed within %i seconds. We may experience a \"time warp\"\n",ConfigServerDatabase::getMaxTimewarp()));
if (ConfigServerDatabase::getSaveAtModulus()!=-1)
{
@@ -617,22 +616,17 @@ void Persister::endBaselines(const NetworkId &objectId, uint32 serverId)
void Persister::saveCompleted(Snapshot *completedSnapshot)
{
{
std::lock_guard<std::mutex> lck(m_savingDeleting_mtx);
std::lock_guard<std::mutex> lck(m_savingDeleting_mtx);
delete completedSnapshot;
completedSnapshot = nullptr;
}
auto i=std::remove(m_savingSnapshots.begin(),m_savingSnapshots.end(),completedSnapshot);
delete completedSnapshot;
completedSnapshot = nullptr;
auto i=std::remove(m_savingSnapshots.begin(),m_savingSnapshots.end(),completedSnapshot);
if (i!=m_savingSnapshots.end())
{
{
std::lock_guard<std::mutex> lck(m_savingDeleting_mtx);
WARNING(true, ("m_SavingSnapshots is not empty and we're nuking everything for some reason. Is this a leak?"));
m_savingSnapshots.erase(i, m_savingSnapshots.end());
}
WARNING(true, ("m_SavingSnapshots is not empty and we're nuking everything for some reason. Is this a leak?"));
m_savingSnapshots.erase(i, m_savingSnapshots.end());
if (m_savingSnapshots.empty() && ConfigServerDatabase::getReportSaveTimes())
{
@@ -663,11 +657,9 @@ void Persister::saveCompleted(Snapshot *completedSnapshot)
}
else
{
std::lock_guard<std::mutex> lck(m_savingDeleting_mtx);
auto j=std::remove(m_savingCharacterSnapshots.begin(),m_savingCharacterSnapshots.end(),completedSnapshot);
WARNING(j==m_savingCharacterSnapshots.end(),("saveCompleted() called w/o snap in m_savingSnapshots or m_savingCharacterSnapshots."));
DEBUG_WARNING(j==m_savingCharacterSnapshots.end(),("saveCompleted() called w/o snap in m_savingSnapshots or m_savingCharacterSnapshots."));
m_savingCharacterSnapshots.erase(j, m_savingCharacterSnapshots.end());
}
@@ -103,12 +103,13 @@ public:
bool m_useGoldDatabase;
DB::ModeQuery::Mode m_mode;
int m_timestamp;
std::mutex snapshot_mtx;
public:
static int getCreationCount() { return ms_creationCount; }
static int getDeletionCount() { return ms_deletionCount; }
static int getPendingCount() { return ms_creationCount - ms_deletionCount; }
std::mutex snapshot_mtx;
private:
static int ms_creationCount;
static int ms_deletionCount;