go-graphite/graphite-clickhouse

Bug with regex alternate

apla opened this issue · 3 comments

apla commented

Query like this

seriesByTag('type_instance=~nonpaged|active|used|wired')

incorrectly translating into

Tag1 LIKE 'type\\\\_instance=nonpaged%' AND match(Tag1, 'type_instance=nonpaged|active|used|wired')

and simply won't work as expected because first value from alternate activates in LIKE and effectively blocking any other alternate. Seems like source of the problem lies in https://github.com/lomik/graphite-clickhouse/blob/master/pkg/where/where.go#L31 . It should be something like:

Tag1 LIKE 'type\\\\_instance=%' AND match(Tag1, 'type_instance=nonpaged|active|used|wired')

And even there regex is incorrect, it matches type_instance=nonpaged or active or used or wired. Wrapping regex value into (?: and ) will produce sane results.

As a temporary workaround I'm wrapping right side of match expression into (?: and ) myself and everything works as expected. For example:

seriesByTag('plugin=memory', 'type_instance=~(?:nonpaged|active|used|wired)')

Hey @apla, can you try the latest master branch?

apla commented

It will take some time, I need to start data collection again.

Please, fill free to reopen it if necessay