-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Add schema tracking support for UDFs #15705
Add schema tracking support for UDFs #15705
Conversation
Signed-off-by: Manan Gupta <manan@planetscale.com>
Signed-off-by: Manan Gupta <manan@planetscale.com>
Signed-off-by: Andres Taylor <andres@planetscale.com>
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Tests
Documentation
New flags
If a workflow is added or modified:
Backward compatibility
|
e86e1bd
to
2706ae8
Compare
6248dc0
to
3f0ec63
Compare
4ee6a93
to
80636f8
Compare
Website Documentation: vitessio/website#1726 |
Signed-off-by: Andres Taylor <andres@planetscale.com>
…gate functions Signed-off-by: Harshit Gangal <harshit@planetscale.com>
… vtgate enableUDFs flag to keep it disabled by default Signed-off-by: Harshit Gangal <harshit@planetscale.com>
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
559b642
to
66f0495
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rest LGTM!
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #15705 +/- ##
==========================================
- Coverage 68.40% 68.37% -0.03%
==========================================
Files 1556 1556
Lines 195121 195247 +126
==========================================
+ Hits 133479 133508 +29
- Misses 61642 61739 +97 ☔ View full report in Codecov by Sentry. |
@@ -989,6 +992,7 @@ enum SchemaTableType { | |||
VIEWS = 0; | |||
TABLES = 1; | |||
ALL = 2; | |||
UDF_AGGREGATE = 3; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we allow only aggregate UDFs? The vtgate flag is just called --enable_udfs
. Release notes also say "any UDFs".
// TestUDFRFC will validate that UDFs are received through the rfc call. | ||
func TestUDFRFC(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this supposed to read TestUDFRPC
??
@@ -883,6 +883,9 @@ message RealtimeStats { | |||
|
|||
// view_schema_changed is to provide list of views that have schema changes detected by the tablet. | |||
repeated string view_schema_changed = 8; | |||
|
|||
// udfs_changed is used to signal that the UDFs have changed on the tablet. | |||
bool udfs_changed = 9; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For tables and views, we track changes as list of changed objects. Why is this a single bool?
Can you have multiple .so files and/or multiple UDFs loaded? I assume so. In which case, if any of them changes, this will be true, and we will reload all of them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For tables and views, the signal that a change has occurred is sent as the name of the table/view. Vtgate can then fetch the new definition for these objects when it wants that info. We did this so that the healtstream doesn't get weighed down with extra traffic that the vtgate might not be interested in - it can decide when to fetch the heavy data load.
For UDFs, the data load is the list and types of UDFs. The vtgate will simply reload the full list when something has changed. With this model, there is no need for the signal to specify what has changed.
detectUdfChange = `SELECT name | ||
FROM ( | ||
SELECT name FROM | ||
mysql.func | ||
|
||
UNION ALL | ||
|
||
SELECT function_name | ||
FROM %s.udfs | ||
) _inner | ||
GROUP BY name | ||
HAVING COUNT(*) = 1 | ||
LIMIT 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way I'm reading this, we'll detect new or deleted UDFs, but not a change to the UDF definition?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, we should also check the types
|
||
// copyUdfs copies user defined function to the udfs table. | ||
copyUdfs = `INSERT INTO %s.udfs(FUNCTION_NAME, FUNCTION_RETURN_TYPE, FUNCTION_TYPE) | ||
SELECT f.name, i.UDF_RETURN_TYPE, f.type FROM mysql.func f left join performance_schema.user_defined_functions i on f.name = i.udf_name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I assume you use i
as an alias for information_schema
, so it makes sense to use p
for performance_schema
// GetFetchUDFsQuery gets the fetch query to retrieve all the UDFs. | ||
func GetFetchUDFsQuery(parser *sqlparser.Parser) (string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are fetching only aggregate UDFs, this func should be renamed to reflect that.
* cherry pick of 15705 * chore: boost integration Signed-off-by: Andres Taylor <andres@planetscale.com> --------- Signed-off-by: Andres Taylor <andres@planetscale.com> Co-authored-by: Andres Taylor <andres@planetscale.com>
Description
Adds the capability of vttablets to notice that aggregate UDFs have been added to a MySQL system.
We need to track these to do planning correctly.
Related Issue(s)
Checklist