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

Long Running Queries #61

Merged
merged 15 commits into from
Oct 3, 2022
Merged

Long Running Queries #61

merged 15 commits into from
Oct 3, 2022

Conversation

kevinwcyu
Copy link
Contributor

@kevinwcyu kevinwcyu commented Aug 30, 2022

Part of #64

@CLAassistant
Copy link

CLAassistant commented Aug 30, 2022

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
0 out of 2 committers have signed the CLA.

❌ andresmgot
❌ iwysiu
You have signed the CLA already but the status is still pending? Let us recheck it.

go.mod Outdated
)

replace github.com/grafana/sqlds/v2 => ../sqlds
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is just a temporary change to be able to test locally.

@kevinwcyu kevinwcyu requested review from a team and fridgepoet and removed request for a team August 31, 2022 12:51
@iwysiu iwysiu self-requested a review September 6, 2022 20:17
Copy link
Collaborator

@sunker sunker left a comment

Choose a reason for hiding this comment

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

Great stuff! Just added a few questions.

It's a shame external plugins can't expose prometheus metrics because it would have been interesting to count the frequence of a status so we could monitor the query cycle.

}

if driverSettings.Timeout != 0 {
tctx, cancel := context.WithTimeout(ctx, driverSettings.Timeout)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure how much sense it makes to make use of the timeout when async mode is enabled. Maybe we should deprecate this feature once the long running queries becomes the default way (or only way) of querying this backend?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, it's a little weird because its the time out for individual operations here instead of the whole data retrieval, which is what it means in sync

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, let's remove it from the async flow then. It will only add confusion.

Copy link
Contributor

Choose a reason for hiding this comment

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

done

}, nil
}

conn, err := ds.driver.Connect(ds.connSettings, q.ConnectionArgs)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Don't we need to use getDBConnectionFromQuery here, like in sqlds?

Copy link
Contributor

Choose a reason for hiding this comment

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

done

Copy link
Collaborator

Choose a reason for hiding this comment

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

You may want to test this manually and make sure this works as expected. You can for example add two query rows in a panel and make sure they use different regions. Then each of the query rows should have one connection each.

Copy link
Contributor

Choose a reason for hiding this comment

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

I looked into it, but from what I can tell there aren't configurable query options for redshift that would force different connections.

pkg/awsds/asyncDatasource.go Outdated Show resolved Hide resolved
pkg/awsds/asyncDatasource.go Show resolved Hide resolved
@iwysiu iwysiu marked this pull request as ready for review September 29, 2022 12:41
Copy link
Contributor

@andresmgot andresmgot left a comment

Choose a reason for hiding this comment

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

Good job! Just a few minor comments. Feel free to ignore

Comment on lines +18 to +19
*sqlds.SQLDatasource
asyncDB AsyncDB
Copy link
Contributor

Choose a reason for hiding this comment

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

this is why I think this is not an "async datasource" but an "async sql data source" since we are still tied to the database architecture of sqlds

Copy link
Contributor

Choose a reason for hiding this comment

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

That's fair, but I think the naming linking it to AWS is specific enough? Also, for context, we're currently discussing removing sqlds and replacing it with a bunch of utility functions so we aren't as stuck with the sqlds architecture.

pkg/awsds/asyncDatasource.go Outdated Show resolved Hide resolved
if err != nil {
return nil, err
}
_, err = ds.SQLDatasource.NewDatasource(settings)
Copy link
Contributor

Choose a reason for hiding this comment

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

this is a bit weird, you are creating a data source using sqlds but not using it?

Copy link
Contributor

Choose a reason for hiding this comment

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

It initializes the sqlds.SQLDatasource that AsyncAWSDatasource is wrapping. Added a comment

Copy link
Contributor

Choose a reason for hiding this comment

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

okay, I think we got the naming there wrong. It should be func (ds *SQLDatasource) Init(settings backend.DataSourceInstanceSettings) (error), also because we already have a NewDatasource that is really generating a new data source.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, it's badly named 😞 Unfortunately I don't think the sqlds function can be renamed at this point without a breaking change.

Copy link
Contributor

Choose a reason for hiding this comment

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

well, you just released that so nobody is using it but here so you have some flexibility if you want to modify it. In any case releases are free and numbers are infinite so there is no problem doing breaking changes :) (at least for things like this)

Copy link
Contributor

Choose a reason for hiding this comment

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

Unfortunately it was already being exported NewDatasource before the long running queries changes 😞 I could deprecate it, but again, if we're planning on just not using it in the future there doesn't seem to be that much of a point.

pkg/awsds/utils.go Outdated Show resolved Hide resolved
pkg/sql/datasource/datasource.go Outdated Show resolved Hide resolved
@iwysiu iwysiu merged commit ab9e896 into main Oct 3, 2022
@iwysiu iwysiu deleted the long-running-queries branch October 3, 2022 15:47
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.

None yet

5 participants