(1.7.8) Massive RAM exhaustion when using SELECT INTO in restore process

Hi,

Using version 1.7.8 on CentOS 7, systems with 256GB RAM.

On instance A I have performed a portable shards backup on instance A, for multiple databases. Shard duration is one day, a single shard was backed up. The backup for one database is around 1GB.
On instance B, I performed restore using -newdb setting. Then started using SELECT INTO to restore missing points. For small databases this works fine. The 1GB shard backup restored into a 3.2GB database. The destination database has quite some data accumulated, and all shards in total are occupying ~800GB on the filesystem. Daily shard’s are between 3 and 5 GB.

When I do the SELECT INTO, InfluxDB climbs from ~64GB up to the server’s 256GB, then OOM happens.

Appreciate some help in understanding how this happens this way (bug, design, something I should be doing differently?)

Regards.