-
Notifications
You must be signed in to change notification settings - Fork 829
scheduler: fragment queue and querier pick-up coordination #6968
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
Open
rubywtl
wants to merge
1
commit into
cortexproject:master
Choose a base branch
from
rubywtl:scheduler/logicalplan_fragment_coordination
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package distributed_execution | ||
|
||
// FragmentKey uniquely identifies a fragment of a distributed logical query plan. | ||
// It combines a queryID (to identify the overall query) and a fragmentID | ||
// (to identify the specific fragment within that query). | ||
type FragmentKey struct { | ||
// QueryID identifies the distributed query this fragment belongs to | ||
queryID uint64 | ||
|
||
// FragmentID identifies this specific fragment within the query | ||
fragmentID uint64 | ||
rubywtl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
// MakeFragmentKey creates a new FragmentKey with the given queryID and fragmentID. | ||
// It's used to track and identify fragments during distributed query execution. | ||
func MakeFragmentKey(queryID uint64, fragmentID uint64) FragmentKey { | ||
return FragmentKey{ | ||
queryID: queryID, | ||
fragmentID: fragmentID, | ||
} | ||
} | ||
|
||
// GetQueryID returns the queryID for the current key | ||
// This ID is shared across all fragments of the same distributed query. | ||
func (f FragmentKey) GetQueryID() uint64 { | ||
return f.queryID | ||
} | ||
|
||
// GetFragmentID returns the ID for this specific fragment | ||
// within its parent query. | ||
func (f FragmentKey) GetFragmentID() uint64 { | ||
return f.fragmentID | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package plan_fragments | ||
|
||
import "github.com/thanos-io/promql-engine/logicalplan" | ||
|
||
type Fragmenter interface { | ||
Fragment(node logicalplan.Node) ([]Fragment, error) | ||
} | ||
|
||
type DummyFragmenter struct { | ||
} | ||
|
||
func (f *DummyFragmenter) Fragment(node logicalplan.Node) ([]Fragment, error) { | ||
// simple logic without distributed optimizer | ||
return []Fragment{ | ||
{ | ||
Node: node, | ||
FragmentID: uint64(1), | ||
ChildIDs: []uint64{}, | ||
IsRoot: true, | ||
}, | ||
}, nil | ||
} | ||
|
||
type Fragment struct { | ||
Node logicalplan.Node | ||
FragmentID uint64 | ||
ChildIDs []uint64 | ||
IsRoot bool | ||
} | ||
|
||
func (s *Fragment) IsEmpty() bool { | ||
if s.Node != nil { | ||
return false | ||
} | ||
if s.FragmentID != 0 { | ||
return false | ||
} | ||
if s.IsRoot { | ||
return false | ||
} | ||
if len(s.ChildIDs) != 0 { | ||
return false | ||
} | ||
return true | ||
} | ||
|
||
func NewDummyFragmenter() Fragmenter { | ||
return &DummyFragmenter{} | ||
} |
46 changes: 46 additions & 0 deletions
46
pkg/distributed_execution/plan_fragments/fragmenter_test.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package plan_fragments | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/cortexproject/cortex/pkg/util/logical_plan" | ||
) | ||
|
||
func TestFragmenter(t *testing.T) { | ||
type testCase struct { | ||
name string | ||
query string | ||
start time.Time | ||
end time.Time | ||
expectedFragments int | ||
} | ||
|
||
now := time.Now() | ||
|
||
// more tests will be added when distributed optimizer and fragmenter are implemented | ||
tests := []testCase{ | ||
{ | ||
name: "simple logical query plan - no fragmentation", | ||
query: "up", | ||
start: now, | ||
end: now, | ||
expectedFragments: 1, | ||
}, | ||
} | ||
|
||
for _, tc := range tests { | ||
t.Run(tc.name, func(t *testing.T) { | ||
lp, err := logical_plan.CreateTestLogicalPlan(tc.query, tc.start, tc.end, 0) | ||
require.NoError(t, err) | ||
|
||
fragmenter := NewDummyFragmenter() | ||
res, err := fragmenter.Fragment((*lp).Root()) | ||
|
||
require.NoError(t, err) | ||
require.Equal(t, tc.expectedFragments, len(res)) | ||
}) | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.