this should let us delete snapshots at the cost of latency

This commit is contained in:
DarthArgus
2016-12-09 03:37:21 +00:00
parent a353c128c3
commit 6418f430f9
5 changed files with 35 additions and 21 deletions
@@ -34,12 +34,12 @@ void ConfigServerDatabase::install(void)
ConfigServerUtility::install();
data = &staticData;
KEY_INT (objvarNameCleanupTime, 60);
KEY_INT (orphanedObjectCleanupTime, 60);
KEY_INT (marketAttributesCleanupTime, 60);
KEY_INT (messagesCleanupTime, 60);
KEY_INT (brokenObjectCleanupTime, 60);
KEY_INT (vendorObjectCleanupTime, 60);
KEY_INT (objvarNameCleanupTime, 10);
KEY_INT (orphanedObjectCleanupTime, 10);
KEY_INT (marketAttributesCleanupTime, 10);
KEY_INT (messagesCleanupTime, 10);
KEY_INT (brokenObjectCleanupTime, 10);
KEY_INT (vendorObjectCleanupTime, 10);
KEY_STRING (customSQLFilename,"");
KEY_BOOL (enableFixBadCells, true);
KEY_STRING (objectTemplateListUpdateFilename,"");
@@ -97,7 +97,7 @@ void ConfigServerDatabase::install(void)
KEY_BOOL (enableGoldDatabase, false);
KEY_STRING (maxGoldNetworkId, "10000000");
KEY_FLOAT (defaultQueueUpdateTimeLimit, 0.25f);
KEY_BOOL (enableDataCleanup, true);
KEY_BOOL (enableDataCleanup, false);
KEY_INT (defaultLazyDeleteBulkBindSize, 100);
KEY_INT (defaultLazyDeleteSleepTime, 1000);
KEY_INT (writeDelay, 0);
@@ -91,13 +91,13 @@ m_queryFetchCount(0)
centralServerConnection = new CentralServerConnection(ConfigServerDatabase::getCentralServerAddress(), ConfigServerDatabase::getCentralServerPort());
NetworkSetupData setup;
setup.maxConnections = 100;
setup.maxConnections = 300;
setup.port = 0;
setup.bindInterface = ConfigServerDatabase::getGameServiceBindInterface();
gameService = new Service(ConnectionAllocator<GameServerConnection>(), setup);
NetworkSetupData cmSetup;
cmSetup.maxConnections = 100;
cmSetup.maxConnections = 300;
cmSetup.port = ConfigServerDatabase::getCommoditiesServerPort();
cmSetup.bindInterface = ConfigServerDatabase::getCommoditiesServerAddress();
commoditiesService = new Service(ConnectionAllocator<CommoditiesServerConnection>(), cmSetup);
@@ -128,7 +128,7 @@ m_queryFetchCount(0)
DB::Server::setDisconnectSleepTime(ConfigServerDatabase::getDisconnectSleepTime());
DB::Server::setFatalOnDataError(ConfigServerDatabase::getFatalOnDataError());
// the DatabaseProcess singleton will want to know when major, connection
// the DatabaseProcess singleton will want to know when major, connection
// oriented events occur. These events are defined in Game, Task and Central
// connection classes.
connectToMessage("CentralConnectionOpened");
@@ -252,7 +252,7 @@ void DatabaseProcess::run(void)
// TODO: sleep longer if idle
if (shouldSleep)
{
Os::sleep(1);
Os::sleep(3);
}
NetworkHandler::dispatch();
@@ -617,15 +617,23 @@ void Persister::endBaselines(const NetworkId &objectId, uint32 serverId)
void Persister::saveCompleted(Snapshot *completedSnapshot)
{
if (completedSnapshot) {
{
std::lock_guard<std::mutex> lck(m_savingDeleting_mtx);
delete completedSnapshot;
completedSnapshot = nullptr;
}
auto i=std::remove(m_savingSnapshots.begin(),m_savingSnapshots.end(),completedSnapshot);
SnapshotListType::iterator i=std::remove(m_savingSnapshots.begin(),m_savingSnapshots.end(),completedSnapshot);
if (i!=m_savingSnapshots.end())
{
m_savingSnapshots.erase(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());
}
if (m_savingSnapshots.empty() && ConfigServerDatabase::getReportSaveTimes())
{
int saveTime = Clock::timeMs() - m_saveStartTime;
@@ -633,7 +641,7 @@ void Persister::saveCompleted(Snapshot *completedSnapshot)
m_totalSaveTime += saveTime;
if (saveTime > m_maxSaveTime)
m_maxSaveTime = saveTime;
DEBUG_REPORT_LOG(true,("Save completed in %i. (Average %i, max %i)\n", saveTime, m_totalSaveTime/m_saveCount, m_maxSaveTime));
LOG("SaveTimes",("Save completed in %i. (Average %i, max %i)", saveTime, m_totalSaveTime/m_saveCount, m_maxSaveTime));
m_lastSaveTime = saveTime;
@@ -646,7 +654,7 @@ void Persister::saveCompleted(Snapshot *completedSnapshot)
DatabaseProcess::getInstance().sendToCentralServer(saveCompleteMessage, true);
LOG("Database",("Sending DatabaseSaveComplete network message to Central."));
}
{
// set the last save completion time (for the monitoring program)
time_t theTime = time(0);
@@ -655,11 +663,13 @@ void Persister::saveCompleted(Snapshot *completedSnapshot)
}
else
{
SnapshotListType::iterator j=std::remove(m_savingCharacterSnapshots.begin(),m_savingCharacterSnapshots.end(),completedSnapshot);
DEBUG_FATAL(i==m_savingCharacterSnapshots.end(),("Programmer bug: SaveCompleted() called with a snapshot that wasn't in m_savingSnapshots or m_savingCharacterSnapshots."));
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."));
m_savingCharacterSnapshots.erase(j, m_savingCharacterSnapshots.end());
DEBUG_REPORT_LOG(ConfigServerDatabase::getReportSaveTimes(),("New character save completed\n"));
}
}
@@ -16,6 +16,8 @@
#include <vector>
#include <set> //TODO: remove when we clean up newCharacterLock hack
#include <mutex>
#include "Unicode.h"
#include "serverNetworkMessages/MessageToPayload.h"
#include "sharedDatabaseInterface/DbModeQuery.h"
@@ -116,8 +118,12 @@ class Persister : public MessageDispatch::Receiver
ServerSnapshotMap m_newCharacterSnapshots;
ObjectSnapshotMap m_objectSnapshotMap;
PendingCharactersType m_pendingCharacters;
SnapshotListType m_savingSnapshots;
SnapshotListType m_savingCharacterSnapshots;
std::mutex m_savingDeleting_mtx;
NewCharacterLockType m_newCharacterLock;
CharactersToDeleteType * m_charactersToDeleteThisSaveCycle;
CharactersToDeleteType * m_charactersToDeleteNextSaveCycle;
@@ -61,8 +61,6 @@ void SwgDatabaseServer::run()
DataCleanupManager cleanupManager;
cleanupManager.runDailyCleanup();
DatabaseProcess::run();
}