pingcap / tidb-lightning

This repository has been moved to https://github.com/pingcap/br
Apache License 2.0
142 stars 66 forks source link

config: allow four byte-size config to be specified using human-readable units ("100 GiB") #471

Closed kennytm closed 3 years ago

kennytm commented 3 years ago

What problem does this PR solve?

Several config specifies a large byte size, which is not very readable (and some DBAs are still unfamiliar with the underscore-as-number-separator TOML feature).

What is changed and how it works?

Using docker/go-units (already used by Dumpling and PD), we support parsing human-readable byte size for the following config:

Byte size can be specified using integers (65536 or 65_536, backward-compatible with existing config), floating point (6.5536e+4), or a string involving byte units ('64k', '64 K', '64KiB', '64 kb', '0.0625 MB', all equivalent).

(This PR is submitted mainly because we expect that disk-quota is also going to need some huge numbers in a custom config, similar to TiKV's ReadableSize struct. Interestingly no such thing exists in TiDB except in dealing with INSPECTION_RULES.)

Check List

Tests

Side effects

Related changes

Release notes

overvenus commented 3 years ago

LGTM