-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
insights: call ingester methods by reference #86146
insights: call ingester methods by reference #86146
Conversation
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.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @maryliag and @matthewtodd)
-- commits
line 4 at r1:
nit: can you add a little more explanation about what this change does?
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.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @maryliag and @matthewtodd)
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.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @j82w, @maryliag, and @matthewtodd)
pkg/sql/sqlstats/insights/ingester.go
line 58 at r1 (raw file):
} func (i *concurrentBufferIngester) Start(ctx context.Context, stopper *stop.Stopper) {
Should a test be added to avoid possible regressions?
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.
Reviewable status: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @j82w and @maryliag)
Previously, maryliag (Marylia Gutierrez) wrote…
nit: can you add a little more explanation about what this change does?
Done.
pkg/sql/sqlstats/insights/ingester.go
line 58 at r1 (raw file):
Previously, j82w wrote…
Should a test be added to avoid possible regressions?
Good q. I'm wondering what that test would look like. I think we could come up with something, but I also think it's unlikely we'll revert to passing by value, so 🤷 Perhaps the data race detector is our friend here. WDYT?
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.
Reviewable status: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @j82w and @maryliag)
pkg/sql/sqlstats/insights/ingester.go
line 58 at r1 (raw file):
Previously, matthewtodd (Matthew Todd) wrote…
Good q. I'm wondering what that test would look like. I think we could come up with something, but I also think it's unlikely we'll revert to passing by value, so 🤷 Perhaps the data race detector is our friend here. WDYT?
The previous behaviour was never part of a release, so this change won't affect any "old" behaviour
Just wondering for learning's sake, are there cases when we want to return an interface in the constructor over the exported struct directly? In the past I recall this was discouraged. |
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.
Reviewable status: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @j82w, @maryliag, and @xinhaoz)
pkg/sql/sqlstats/insights/insights.go
line 141 at r2 (raw file):
Previously, xinhaoz (Xin Hao Zhang) wrote…
Just wondering for learning's sake, are there cases when we want to return an interface in the constructor over the exported struct directly? In the past I recall this was discouraged.
Oh, that's interesting! Now that you mention it, I kind of recall those conversations, but I don't really remember the reasons. I'll ask in #go-learners.
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.
Reviewable status: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @j82w, @maryliag, and @xinhaoz)
pkg/sql/sqlstats/insights/insights.go
line 141 at r2 (raw file):
Previously, matthewtodd (Matthew Todd) wrote…
Oh, that's interesting! Now that you mention it, I kind of recall those conversations, but I don't really remember the reasons. I'll ask in #go-learners.
Googling first, this result doesn't seem particularly Go-specific; you could just as easily balance the same forces the other way, as is done in, say, Java, where returning interfaces is the norm. I wonder if the difference is purely cultural, or if there's some technical benefit?
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.
Reviewable status: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @j82w, @maryliag, and @xinhaoz)
pkg/sql/sqlstats/insights/insights.go
line 141 at r2 (raw file):
Previously, matthewtodd (Matthew Todd) wrote…
Googling first, this result doesn't seem particularly Go-specific; you could just as easily balance the same forces the other way, as is done in, say, Java, where returning interfaces is the norm. I wonder if the difference is purely cultural, or if there's some technical benefit?
From what I've digested, I think it probably does make sense to return a struct here. (Though the interface was maybe slightly helpful tactically in the move to wrap the ingester around the registry.)
In general, I've been feeling like the Registry interface is too big: the needs of the ingester (Start
) are completely separate from the needs of the registry (enabled
), and there's a reader/writer distinction just waiting to be made. I'll take a little time to play with it on Friday to see if something simpler shakes out.
Fixes the data race observed in #85988. Passing this data structure by value meant that the `fullHandler` was working with a different object than the external callers. Release justification: Category 3: Fixes for high-priority or high-severity bugs in existing functionality Release note: None
bors r+ |
https://medium.com/@cep21/preemptive-interface-anti-pattern-in-go-54c18ac0668a |
Build succeeded: |
Fixes the data race observed in #85988. Passing this data structure by
value meant that the
fullHandler
was working with a different objectthan the external callers.
Release justification: Category 3: Fixes for high-priority or
high-severity bugs in existing functionality
Release note: None