ConfigReloader: use last_write_time for FileWithTimestamp

Previously it used `FS::getModificationTime` which has only a second precision.
This caused an issue in some cases where the configuration has been changed
more frequently than once per second, and the change wasn't propagated. This
commit fixes that issue.
Closes #53276
This commit is contained in:
Mikhail Koviazin 2023-08-30 11:06:19 +00:00
parent 88128db26f
commit 021c607725
No known key found for this signature in database
GPG Key ID: 0EEAA1BF0787792F

View File

@ -164,10 +164,10 @@ void ConfigReloader::reloadIfNewer(bool force, bool throw_on_error, bool fallbac
struct ConfigReloader::FileWithTimestamp
{
std::string path;
time_t modification_time;
fs::file_time_type modification_time;
FileWithTimestamp(const std::string & path_, time_t modification_time_)
: path(path_), modification_time(modification_time_) {}
explicit FileWithTimestamp(const std::string & path_)
: path(path_), modification_time(fs::last_write_time(path_)) {}
bool operator < (const FileWithTimestamp & rhs) const
{
@ -184,7 +184,7 @@ struct ConfigReloader::FileWithTimestamp
void ConfigReloader::FilesChangesTracker::addIfExists(const std::string & path_to_add)
{
if (!path_to_add.empty() && fs::exists(path_to_add))
files.emplace(path_to_add, FS::getModificationTime(path_to_add));
files.emplace(path_to_add);
}
bool ConfigReloader::FilesChangesTracker::isDifferOrNewerThan(const FilesChangesTracker & rhs)