Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

table_resolver refactor - introduce patternSplitter, decisionMerger #925

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

avelanarius
Copy link
Member

@avelanarius avelanarius commented Oct 29, 2024

This PR changes the way patterns (wildcards such as logs*) are handled by table_resolver.

Previously, many table_resolver rules had two code paths - one code path for a single index (e.g. logs1) and one code path for patterns (e.g. logs1,logs2 or logs*), making those rules more complicated. Moreover, one rule makeCheckIfPatternMatchesAllConnectors was the primary one to handle patterns and it contained fragments of other rules.

This PR introduces patternSplitter, decisionMerger. The table_resolver now works like this:

  1. patternSplitter splits a pattern (e.g. logs*) into concrete single indexes (e.g. logs1, logs2)
  2. Existing rules are evaluated on each single index separately
  3. decisionMerger merges decisions of single indexes, making sure that the decisions are compatible. It yields a single decision.

@avelanarius avelanarius force-pushed the table_resolver_refactor branch 6 times, most recently from 61cdda1 to 0bfe29b Compare November 5, 2024 05:18
@avelanarius avelanarius changed the title [WIP] table_resolver refactor - introduce patternSplitter, decisionMerger table_resolver refactor - introduce patternSplitter, decisionMerger Nov 5, 2024
@avelanarius avelanarius marked this pull request as ready for review November 5, 2024 09:34
@avelanarius avelanarius requested a review from a team as a code owner November 5, 2024 09:34
@pdelewski
Copy link
Contributor

I really like logic :)

if lhsClickhouse, ok := connDecisionLhs.(*ConnectorDecisionClickhouse); ok {
if lhsClickhouse.ClickhouseTableName != rhsClickhouse.ClickhouseTableName {
return nil, &Decision{
Reason: "Inconsistent ClickHouse table usage",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add more details here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in last commit - made the reason (and corresponding Err) more clear.

} else {
if !reflect.DeepEqual(lhsClickhouse, rhsClickhouse) {
return nil, &Decision{
Reason: "Inconsistent ClickHouse table usage",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same reason is returned above. There is no way to distinguish which one rule has been fired.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in last commit - made the reason (and corresponding Err) more clear.

}
if !foundMatching {
return nil, &Decision{
Reason: "Inconsistent connectors",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above, we need more details here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in last commit - made the reason (and corresponding Err) more clear.

A/B testing is turned on in the configuration by specifying
two targets: ClickHouse and Elastic (`target: [ch, es]`). table_resolver
correctly handles it for single index case, but it's not working
correctly for the pattern case (even if the pattern matches only
a single index with A/B testing requested).

Adding a (skipped) test for such case (a proper fix needs
some discussion).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants