influxdata / influxdata/influxdb
influxd restore fails for a database name containing periods
- Dominant language
- Rust
- Stars
- 31.7k
- Forks
- 3.7k
- Avg merge
- 13h 37m
- Merged PRs (30d)
- 8
Description
If you have a database name containing periods, then it is possible to backup the database, but it is not possible to restore the backup.
__Steps to reproduce:__
Create a database with a `.` in the name, take a backup, and attempt to restore it
1. `CREATE DATABASE "hcloud-infra.telegraf"`
2. `influxd backup -host infra-influxdb1:8088 -database hcloud-infra.telegraf hcloud-infra.telegraf`
3. `influxd restore -online -host infra-influxdb1:8088 -db hcloud-infra.telegraf -newdb 'hcloud-infra.telegraf-restore' hcloud-infra.telegraf`
Note that the backup shard files will contain an extra `.`, because the database name is included at the start of the filename:
```
bash-4.4$ influxd backup -host infra-influxdb1:8088 -database hcloud-infra.telegraf hcloud-infra.telegraf
2020/02/06 13:43:24 backing up metastore to hcloud-infra.telegraf/meta.00
2020/02/06 13:43:24 backing up db=hcloud-infra.telegraf
2020/02/06 13:43:24 backing up db=hcloud-infra.telegraf rp=default shard=359 to hcloud-infra.telegraf/hcloud-infra.telegraf.default.00359.00 since 0001-01-01T00:00:00Z
2020/02/06 13:43:25 backing up db=hcloud-infra.telegraf rp=default shard=362 to hcloud-infra.telegraf/hcloud-infra.telegraf.default.00362.00 since 0001-01-01T00:00:00Z
2020/02/06 13:43:25 backing up db=hcloud-infra.telegraf rp=default shard=365 to hcloud-infra.telegraf/hcloud-infra.telegraf.default.00365.00 since 0001-01-01T00:00:00Z
```
__Expected behavior:__
The database shards should be restored to a new `hcloud-infra.telegraf-restore` database.
__Actual behavior:__
The metastore snapshot is succesfully restored and the new `hcloud-infra.telegraf-restore` database is created, but the shard restore fails and crashes with an error:
```
bash-4.4$ influxd restore -online -host infra-influxdb1:8088 -db hcloud-infra.telegraf -newdb 'hcloud-infra.telegraf-restore' hcloud-infra.telegraf
2020/02/06 13:48:10 Using metastore snapshot: hcloud-infra.telegraf/meta.00
2020/02/06 13:48:11 Restoring live from backup hcloud-infra.telegraf/hcloud-infra.telegraf.*
2020/02/06 13:48:11 Skipping mis-named backup file: hcloud-infra.telegraf/hcloud-infra.telegraf.default.00359.00
2020/02/06 13:48:11 error updating shards: strconv.ParseUint: parsing "default": invalid syntax
restore: strconv.ParseUint: parsing "default": invalid syntax
```
__Environment info:__
* System info: `Linux 3.10.0-1062.12.1.el7.x86_64 x86_64`
* InfluxDB version: `InfluxDB v1.7.8 (git: 1.7 ff383cdc0420217e3460dabe17db54f8557d95b6)`
* Other relevant environment details: Using the Docker `influxdb:1.7.8` image
Contributor guide
Research direction
Start with the `influxd restore` command and the backup filenames shown in the reproduction, then trace how shard filenames are parsed during online restore. Reproduce the failure with the provided database name and commands; done means the shard files restore successfully into `hcloud-infra.telegraf-restore` without the parse error.
Written by the indexing model from the issue text.
Assessment
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100