diff --git a/docs/CHANGELOG.asciidoc b/docs/CHANGELOG.asciidoc index eb4b2038ce..b264bfb44c 100644 --- a/docs/CHANGELOG.asciidoc +++ b/docs/CHANGELOG.asciidoc @@ -80,6 +80,12 @@ to the model. (See {ml-pull}214[#214].) == {es} version 7.0.0-alpha1 +== {es} version 6.8.2 + +=== Bug Fixes + +* Don't write model size stats when job is closed without any input {ml-pull}512[#512] (issue: {ml-issue}394[#394]) + == {es} version 6.7.2 === Enhancements diff --git a/lib/api/CAnomalyJob.cc b/lib/api/CAnomalyJob.cc index 93192dd2a9..7cca77b188 100644 --- a/lib/api/CAnomalyJob.cc +++ b/lib/api/CAnomalyJob.cc @@ -221,14 +221,14 @@ bool CAnomalyJob::handleRecord(const TStrStrUMap& dataRowFields) { void CAnomalyJob::finalise() { // Persist final state of normalizer iff an input record has been handled or time has been advanced. - if (this->isPersistenceNeeded("quantiles state")) { + if (this->isPersistenceNeeded("quantiles state and model size stats")) { m_JsonOutputWriter.persistNormalizer(m_Normalizer, m_LastNormalizerPersistTime); - } - // Prune the models so that the final persisted state is as neat as possible - this->pruneAllModels(); + // Prune the models so that the final persisted state is as neat as possible + this->pruneAllModels(); - this->refreshMemoryAndReport(); + this->refreshMemoryAndReport(); + } // Wait for any ongoing periodic persist to complete, so that the data adder // is not used by both a periodic periodic persist and final persist at the @@ -1270,6 +1270,12 @@ void CAnomalyJob::writeOutModelPlot(const TModelPlotDataVec& modelPlotData) { } void CAnomalyJob::refreshMemoryAndReport() { + if (m_LastFinalisedBucketEndTime < m_ModelConfig.bucketLength()) { + LOG_ERROR(<< "Cannot report memory usage because last finalized bucket end time (" + << m_LastFinalisedBucketEndTime << ") is smaller than bucket span (" + << m_ModelConfig.bucketLength() << ')'); + return; + } // Make sure model size stats are up to date and then send a final memory // usage report for (const auto& detector_ : m_Detectors) {