Merge pull request #7051 from Icinga/bugfix/influxdb-flush-buffer

InfluxDB/Elasticsearch: Flush only if there's data in the buffer
This commit is contained in:
Michael Friedrich 2019-03-27 12:16:07 +01:00 committed by GitHub
commit bea24c20f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View File

@ -398,6 +398,10 @@ void ElasticsearchWriter::FlushTimeout()
void ElasticsearchWriter::Flush() void ElasticsearchWriter::Flush()
{ {
/* Flush can be called from 1) Timeout 2) Threshold 3) on shutdown/reload. */
if (m_DataBuffer.empty())
return;
/* Ensure you hold a lock against m_DataBuffer so that things /* Ensure you hold a lock against m_DataBuffer so that things
* don't go missing after creating the body and clearing the buffer. * don't go missing after creating the body and clearing the buffer.
*/ */

View File

@ -421,10 +421,6 @@ void InfluxdbWriter::FlushTimeoutWQ()
{ {
AssertOnWorkQueue(); AssertOnWorkQueue();
// Flush if there are any data available
if (m_DataBuffer.empty())
return;
Log(LogDebug, "InfluxdbWriter") Log(LogDebug, "InfluxdbWriter")
<< "Timer expired writing " << m_DataBuffer.size() << " data points"; << "Timer expired writing " << m_DataBuffer.size() << " data points";
@ -433,6 +429,10 @@ void InfluxdbWriter::FlushTimeoutWQ()
void InfluxdbWriter::Flush() void InfluxdbWriter::Flush()
{ {
/* Flush can be called from 1) Timeout 2) Threshold 3) on shutdown/reload. */
if (m_DataBuffer.empty())
return;
Log(LogDebug, "InfluxdbWriter") Log(LogDebug, "InfluxdbWriter")
<< "Flushing data buffer to InfluxDB."; << "Flushing data buffer to InfluxDB.";