Skip to content

Commit

Permalink
Merge pull request #11 from innogames/fix_optimize_interval
Browse files Browse the repository at this point in the history
- Fix error `No alias for subquery` for info queries in README.md
- Add manual about new versions publishing
- Fix query to optimize partitions with `max(g.age) < optimize-interval`
- Fix loop and optimize intervals' description
  • Loading branch information
Felixoid authored Aug 17, 2020
2 parents 53b167f + f3281ad commit 71762f0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ make deb
make rpm
```

### Publish new version

After checks are green for the latest commit in master, create a tag with format `v1.2.3` with 1 as major, 2 as minor and 3 as patch version.
The workflow will build packages and upload them as release's assets.

In the same time, the Docker Hub will build the images for the latest and `1.2.3` tags.

## Docker

To build docker image locally run:
Expand Down Expand Up @@ -84,7 +91,7 @@ SELECT
max(max_date) AS max_date,
formatReadableSize(sum(bytes_on_disk)) AS size,
sum(rows) AS rows
FROM system.parts
FROM system.parts AS p
INNER JOIN
(
SELECT
Expand All @@ -95,7 +102,7 @@ INNER JOIN
GROUP BY
database,
table
) USING (database, table)
) AS g USING (database, table)
GROUP BY
database,
table,
Expand All @@ -120,7 +127,7 @@ SELECT
max(max_date) AS max_date,
formatReadableSize(sum(bytes_on_disk)) AS size,
sum(rows) AS rows
FROM system.parts
FROM system.parts AS p
INNER JOIN
(
SELECT
Expand All @@ -131,7 +138,7 @@ INNER JOIN
GROUP BY
database,
table
) USING (database, table)
) AS g USING (database, table)
GROUP BY
database,
table,
Expand Down Expand Up @@ -171,10 +178,10 @@ Usage of graphite-ch-optimizer:
-c, --config string Filename of the custom config. CLI arguments override it
--print-defaults Print default config values and exit
-v, --version Print version and exit
--optimize-interval duration The active partitions won't be optimized more than once per this interval, seconds (default 72h0m0s)
--optimize-interval duration The partition will be merged after having no writes for more than the given duration (default 72h0m0s)
-s, --server-dsn string DSN to connect to ClickHouse server (default "tcp://localhost:9000?&optimize_throw_if_noop=1&receive_timeout=3600&debug=true")
-n, --dry-run Will print how many partitions would be merged without actions
--loop-interval duration Daemon will check if there partitions to merge once per this interval, seconds (default 1h0m0s)
--loop-interval duration Daemon will check if there partitions to merge once per this interval (default 1h0m0s)
--one-shot Program will make only one optimization instead of working in the loop (true if dry-run)
--log-level string Valid options are: panic, fatal, error, warn, warning, info, debug, trace
--output string The logs file. '-' is accepted as STDOUT (default "-")
Expand Down
9 changes: 4 additions & 5 deletions graphite-ch-optimizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,10 @@ GROUP BY
partition_id
-- modified_at < rollup_time: the merge has not been applied for the current retention policy
-- parts > 1: merge should be applied because of new parts
-- modified_at < (now() - @Interval): we want to merge active partitions only once an interval
-- @Interval < age: do not touch currently active partitions
-- modified_at < (now() - @Interval): we want to merge active partitions only once per interval,
-- so do not touch partitions with current active inserts
HAVING ((modified_at < rollup_time) OR (parts > 1))
AND (modified_at < (now() - @Interval))
AND ( @Interval < age)
ORDER BY
table ASC,
partition_name ASC,
Expand Down Expand Up @@ -165,11 +164,11 @@ func processFlags() error {
// ClickHouse set
fc := pflag.NewFlagSet("clickhouse", 0)
fc.StringP("server-dsn", "s", viper.GetString("clickhouse.server-dsn"), "DSN to connect to ClickHouse server")
fc.Duration("optimize-interval", viper.GetDuration("clickhouse.optimize-interval"), "The active partitions won't be optimized more than once per this interval, seconds")
fc.Duration("optimize-interval", viper.GetDuration("clickhouse.optimize-interval"), "The partition will be merged after having no writes for more than the given duration")
// Daemon set
fd := pflag.NewFlagSet("daemon", 0)
fd.Bool("one-shot", viper.GetBool("daemon.one-shot"), "Program will make only one optimization instead of working in the loop (true if dry-run)")
fd.Duration("loop-interval", viper.GetDuration("daemon.loop-interval"), "Daemon will check if there partitions to merge once per this interval, seconds")
fd.Duration("loop-interval", viper.GetDuration("daemon.loop-interval"), "Daemon will check if there partitions to merge once per this interval")
fd.BoolP("dry-run", "n", viper.GetBool("daemon.dry-run"), "Will print how many partitions would be merged without actions")
// Logging set
fl := pflag.NewFlagSet("logging", 0)
Expand Down

0 comments on commit 71762f0

Please sign in to comment.