influxdb icon indicating copy to clipboard operation
influxdb copied to clipboard

InfluxDB 1.7 uses way more memory and disk i/o than 1.6.4

Open scotloach opened this issue 8 years ago • 63 comments

System info: InfluxDB 1.7, upgraded from 1.6.4. Running on the standard Docker image.

Steps to reproduce:

I upgraded a large InfluxDB server to InfluxDB 1.7. Nothing else changed. We are running two InfluxDB servers of a similar size, the other one was left at 1.6.4.

This ran fine for about a day, then it started running into our memory limit and continually OOMing. We upped the memory and restarted. It ran fine for about 4 hours then started using very high disk i/o (read) which caused our stats writing processes to back off.

Please see the timeline on the heap metrics below:

  • you can see relatively stable heap usage before we upgraded at 6am on Nov 9
  • at around 4pm there is a step-up in heap usage
  • around 11:30pm there is another step-up and it starts hitting the limit (OOM, causes a restart)
  • at 12:45pm on the 10th we restart with more RAM
  • around 4 hours later it starts using high i/o and you can see spikes in heap usage

image

scotloach avatar Nov 11 '18 02:11 scotloach

I've spent a lot more time trying to understand what's happening here. I've also downgraded back to 1.6.4 and the same thing happens - so I'm suspecting that after the upgrade, maybe one of the shards got corrupted in some way. What seems to be happening is, when InfluxDB starts up, everything is fine. At some time after this, the read I/O load suddenly gets maxed out, this doesn't ever seem to stop until InfluxDB is restarted. I'm attaching here a profile I took while it was in this state (this is 1.6.4). profiles.tar.gz

scotloach avatar Nov 12 '18 03:11 scotloach

I have encountered the same problem. The read load continues to be high.

image

chenxu1990 avatar Nov 12 '18 07:11 chenxu1990

Same problem here, visible increase of memory usage after upgrade and performance of the queries dropped dramatically - the platform is borderline unusable at the moment... No other changes than upgrading version to 1.7

image

nktl avatar Nov 12 '18 11:11 nktl

@scotloach @cxhuawei @nktl thanks for your reports. We will prioritise an investigation into this issue today.

In the mean time, if you have any more information on your setups that would be very helpful. For example:

  • What index are you using (TSI / inmem)?
  • How many shards do you have?
  • What's your database cardinality? SHOW SERIES CARDINALITY.
  • If you could provide profiles whilst your 1.7 system is using lots of heap (the higher the heap use the better) that would really help us. You can do curl -o profiles.tar.gz http://localhost:8086/debug/pprof/all?cpu=true It will take 30s for the request to complete.

@scotloach thanks for your 1.6.4 profiles. When your downgraded back to 1.6.4 would you describe the system behaviour as being exactly the same as 1.7.0 (same heap usage, CPU and IO) or would you say there were differences in the performance characteristics?

I will look at your profiles this morning.

e-dard avatar Nov 12 '18 12:11 e-dard

All the following comment was wrong, analyzed the profile using the wrong binary, corrected version here


Just for context, I analyzed a bit the heap profile that @scotloach provided, here's the top heap consuming calls.

Total: 88992.1 MB
 33940.0  38.1%  38.1%  33991.0  38.2% github.com/influxdata/influxdb/prometheus/remote..Unmarshal
 14590.3  16.4%  54.5%  14590.3  16.4% runtime.getitab
  7334.0   8.2%  62.8%   9060.1  10.2% runtime..sysAlloc
  4771.5   5.4%  68.1%   5255.3   5.9% runtime..Error
  2462.0   2.8%  70.9%   2462.0   2.8% github.com/influxdata/influxdb/query..Close
  2262.0   2.5%  73.4%   3940.5   4.4% text/tabwriter..append
  1790.8   2.0%  75.5%   4249.8   4.8% github.com/influxdata/influxdb/query..Next
  1662.8   1.9%  77.3%   1665.8   1.9% github.com/influxdata/influxdb/vendor/collectd.org/network.parseValues
  1508.5   1.7%  79.0%   1567.5   1.8% bytes..String
  1369.5   1.5%  80.6%  13209.1  14.8% type..eq.github.com/influxdata/influxdb/vendor/github.com/BurntSushi/toml.item

Attached the profile image too.

profile001

fntlnz avatar Nov 12 '18 12:11 fntlnz

Could you please also provide some data from the output of the following:

influx_inspect dumptsm -index path/to/tsm/file/in/shard/being/compacted/0000000xy-00000000z.tsm

You don't need to provide all the output (there could be a lot), we're just interested in seeing if the min time and max time are correct on the TSM index data.

e-dard avatar Nov 12 '18 12:11 e-dard

@fntlnz I'm not sure you're using the right binary. When I look at the heap profile I see all the heap being used by the decoders for a compaction:

Showing top 10 nodes out of 130
      flat  flat%   sum%        cum   cum%
   33.57GB 37.40% 37.40%    33.57GB 37.40%  github.com/influxdata/influxdb/tsdb/engine/tsm1.DecodeFloatBlock
   19.43GB 21.65% 59.05%    27.74GB 30.91%  github.com/influxdata/influxdb/tsdb/index/tsi1.(*LogFile).execSeriesEntry
    7.07GB  7.88% 66.92%     7.79GB  8.68%  github.com/influxdata/influxdb/tsdb/index/tsi1.(*logTagValue).addSeriesID
    2.66GB  2.96% 69.89%     2.66GB  2.96%  github.com/influxdata/influxdb/pkg/rhh.(*HashMap).insert
    2.50GB  2.79% 72.68%     6.14GB  6.84%  github.com/influxdata/influxdb/tsdb/index/inmem.(*Index).CreateSeriesListIfNotExists
    2.24GB  2.49% 75.17%     2.24GB  2.49%  github.com/influxdata/influxdb/models.Tags.Clone
    1.92GB  2.14% 77.31%     6.01GB  6.69%  github.com/influxdata/influxdb/tsdb/engine/tsm1.(*Engine).WritePoints
    1.63GB  1.82% 79.13%     1.63GB  1.82%  github.com/influxdata/influxdb/tsdb/engine/tsm1.(*entry).add
    1.57GB  1.75% 80.88%     3.24GB  3.61%  github.com/influxdata/influxdb/pkg/rhh.(*HashMap).grow
    1.30GB  1.44% 82.32%     5.52GB  6.15%  github.com/influxdata/influxdb/tsdb.(*SeriesIndex).execEntry

This issue looks very similar to the one we recently fixed, which is somewhat confusing.

e-dard avatar Nov 12 '18 12:11 e-dard

Thanks!

Regarding your questions:

  • What index are you using (TSI / inmem)? index-version = "tsi1"

  • How many shards do you have?

Around 10000

  • What's your database cardinality? SHOW SERIES CARDINALITY.

There are roughly 100 databases, the 'worst' one has carnality of around 40000

  • If you could provide profiles whilst your 1.7 system is using lots of heap (the higher the heap use the better) that would really help us. You can do curl -o profiles.tar.gz http://localhost:8086/debug/pprof/all?cpu=true It will take 30s for the request to complete.

Getting 404 on this influx endpoint for some reason

nktl avatar Nov 12 '18 12:11 nktl

@nktl thanks. Do you have pprof-enabled = true in the http section of your config? It defaults to true, but maybe you disabled it?

e-dard avatar Nov 12 '18 12:11 e-dard

@nktl thanks. Do you have pprof-enabled = true in the http section of your config? It defaults to true, but maybe you disabled it?

Yes, that was it! Unfortunately cannot restart influx at the moment to apply this, would have to be a bit later today or tomorrow.

nktl avatar Nov 12 '18 12:11 nktl

Sorry for the confusion, uploading the profile output with the right binary from the downloads page.

profile002

and here's the top calls.

Dropped 549 nodes (cum <= 0.45GB)
Showing top 10 nodes out of 130
      flat  flat%   sum%        cum   cum%
   33.57GB 37.40% 37.40%    33.57GB 37.40%  github.com/influxdata/influxdb/tsdb/engine/tsm1.DecodeFloatBlock
   19.43GB 21.65% 59.05%    27.74GB 30.91%  github.com/influxdata/influxdb/tsdb/index/tsi1.(*LogFile).execSeriesEntry
    7.07GB  7.88% 66.92%     7.79GB  8.68%  github.com/influxdata/influxdb/tsdb/index/tsi1.(*logTagValue).addSeriesID
    2.66GB  2.96% 69.89%     2.66GB  2.96%  github.com/influxdata/influxdb/pkg/rhh.(*HashMap).insert
    2.50GB  2.79% 72.68%     6.14GB  6.84%  github.com/influxdata/influxdb/tsdb/index/inmem.(*Index).CreateSeriesListIfNotExists
    2.24GB  2.49% 75.17%     2.24GB  2.49%  github.com/influxdata/influxdb/models.Tags.Clone
    1.92GB  2.14% 77.31%     6.01GB  6.69%  github.com/influxdata/influxdb/tsdb/engine/tsm1.(*Engine).WritePoints
    1.63GB  1.82% 79.13%     1.63GB  1.82%  github.com/influxdata/influxdb/tsdb/engine/tsm1.(*entry).add
    1.57GB  1.75% 80.88%     3.24GB  3.61%  github.com/influxdata/influxdb/pkg/rhh.(*HashMap).grow
    1.30GB  1.44% 82.32%     5.52GB  6.15%  github.com/influxdata/influxdb/tsdb.(*SeriesIndex).execEntry

fntlnz avatar Nov 12 '18 12:11 fntlnz

@nktl ok thanks. In the meantime, if you can identify a shard that you think is being continually compacted do you think you could send it to us? We have a secure SFTP site for uploading it. Feel free to email me edd at the product name dot com. It may help us get to the bottom of the issue more quickly.

e-dard avatar Nov 12 '18 13:11 e-dard

For my system, I'm using tsi, about 6K shards, 70 databases. Largest DB has about 8M series.

I use 7 day shards for the most part so they all rolled over last evening, and it's been stable and looking good on the 1.64 release since then. I'm happy to help you out with your investigation if I can, but I'm not going to put 1.7 back on it anytime soon.

scotloach avatar Nov 12 '18 14:11 scotloach

@e-dard, the following line using DecodeFloatBlock I would expect to be for query load, as compaction should be using the new DecodeFloatArrayBlock API

33.57GB 37.40% 37.40%    33.57GB 37.40%  github.com/influxdata/influxdb/tsdb/engine/tsm1.DecodeFloatBlock

stuartcarnie avatar Nov 12 '18 14:11 stuartcarnie

Another thing I noticed, the current _internal.monitor shard was growing very fast when this was happening, it churned through about 250GB of disk before I noticed and deleted that shard. I'm not sure what it was and I needed to clean the space up.

scotloach avatar Nov 12 '18 14:11 scotloach

That is a really great lead, @scotloach. Perhaps the behavior of the _internal monitoring database has changed.

stuartcarnie avatar Nov 12 '18 14:11 stuartcarnie

My instinct is more that something was happening (compaction I guess?) and got into some internal loop, this process was continually reading from disk and as a side effect was updating some state in the monitor db.

scotloach avatar Nov 12 '18 14:11 scotloach

@stuartcarnie The profiles are taken from a 1.6.4 release. @scotloach downgraded when they inititially saw problems.

e-dard avatar Nov 12 '18 14:11 e-dard

My current theory based on this ticket and #10465 are that there is a compaction bug somewhere, but it's not caused by a problem with encoding bad TSM data.

The symptoms seem to be when upgrading to 1.7.0 a full compaction seems to go on indefinitely. Profiles from this ticket, and #10465 indicate a significant amount of time decoding blocks and checking for overlaps, suggesting the routines are being called many time.

  • If the shard rolls over and the user downgrades to 1.6.4 and restarts then the issue appears to go away (@scotloach has seen this);
  • if the user restarts whilst staying on 1.7.0 the issue does not go away (as seen by @conet in #10465).

I'm awaiting logs from #10465 to see if there are any clues there.

e-dard avatar Nov 12 '18 14:11 e-dard

To clarify, downgrading to 1.6.4 and restarting did not make the issue go away. The issue seems to have gone away now that I'm writing to new shards created by 1.6.4. It's only been about 12 hours since I restarted it post shard-rollover, so it's possible it will happen again, I'm keeping a close eye on it.

scotloach avatar Nov 12 '18 14:11 scotloach