aboutsummaryrefslogtreecommitdiff
path: root/src/database
diff options
context:
space:
mode:
authorLoïc Blot <loic.blot@unix-experience.fr>2019-01-04 10:20:04 +0100
committerLoïc Blot <loic.blot@unix-experience.fr>2019-01-04 10:20:04 +0100
commitc1d7dbfc38e8f48b42d957afad2696a8e56b740b (patch)
tree53db583fc199c9eb096c15e6ffa6c85539a54c0d /src/database
parent07177190734b0e5c17be18d0bf5d509c5226af2f (diff)
downloadminetest-c1d7dbfc38e8f48b42d957afad2696a8e56b740b.tar.gz
minetest-c1d7dbfc38e8f48b42d957afad2696a8e56b740b.tar.bz2
minetest-c1d7dbfc38e8f48b42d957afad2696a8e56b740b.zip
Fix various player save issues (performance penalty on sql backends + bugs)
* PostgreSQL & SQLite3 doesn't setModified(false) on RemotePlayer, then player is saved on each server save call. This results in heavy useless writes. * PostgreSQL & SQLite3 ack engine meta write whereas db commit hasn't been performed. If commit failed write has failed. We mustn't notify engine write is done. * serializing player meta must not setModified(false) because it didn't ensure write has been done * add RemotePlayer::on_successfull_save callback to do the flag update on a successful save
Diffstat (limited to 'src/database')
-rw-r--r--src/database/database-files.cpp3
-rw-r--r--src/database/database-postgresql.cpp3
-rw-r--r--src/database/database-sqlite3.cpp3
3 files changed, 6 insertions, 3 deletions
diff --git a/src/database/database-files.cpp b/src/database/database-files.cpp
index f42535348..b1c79c94a 100644
--- a/src/database/database-files.cpp
+++ b/src/database/database-files.cpp
@@ -105,7 +105,8 @@ void PlayerDatabaseFiles::savePlayer(RemotePlayer *player)
if (!fs::safeWriteToFile(path, ss.str())) {
infostream << "Failed to write " << path << std::endl;
}
- player->setModified(false);
+
+ player->on_successful_save();
}
bool PlayerDatabaseFiles::removePlayer(const std::string &name)
diff --git a/src/database/database-postgresql.cpp b/src/database/database-postgresql.cpp
index eec838ef0..f5f8e3adf 100644
--- a/src/database/database-postgresql.cpp
+++ b/src/database/database-postgresql.cpp
@@ -527,8 +527,9 @@ void PlayerDatabasePostgreSQL::savePlayer(RemotePlayer *player)
};
execPrepared("save_player_metadata", 3, meta_values);
}
- sao->getMeta().setModified(false);
endSave();
+
+ player->on_successful_save();
}
bool PlayerDatabasePostgreSQL::loadPlayer(RemotePlayer *player, PlayerSAO *sao)
diff --git a/src/database/database-sqlite3.cpp b/src/database/database-sqlite3.cpp
index aa156bbbd..7a79fb187 100644
--- a/src/database/database-sqlite3.cpp
+++ b/src/database/database-sqlite3.cpp
@@ -528,9 +528,10 @@ void PlayerDatabaseSQLite3::savePlayer(RemotePlayer *player)
sqlite3_vrfy(sqlite3_step(m_stmt_player_metadata_add), SQLITE_DONE);
sqlite3_reset(m_stmt_player_metadata_add);
}
- sao->getMeta().setModified(false);
endSave();
+
+ player->on_successful_save();
}
bool PlayerDatabaseSQLite3::loadPlayer(RemotePlayer *player, PlayerSAO *sao)