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
cmd/syncthing: Add more stats to usage reports (ref #3628) #4347
Conversation
Apart from tests, what else needs to be done here @calmh? |
I think either implement what we discussed on IRC about retaining the previous report version until the new one is accepted, or a huge push to get all the stuff we really want into the report in in one swoop... Not necessarily in this PR of course, but before we let this into the wild... |
So added incremental support, but did it without paying too much attention or thinking about it. |
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.
Uh, it looks reasonable but my review time got interrupted by kids and concentration went out the window so I'll make another attempt soon
cmd/syncthing/usage_report.go
Outdated
|
||
func (s *usageReportingService) CommitConfiguration(from, to config.Configuration) bool { | ||
if from.Options.URAccepted != to.Options.URAccepted || from.Options.URUniqueID != to.Options.URUniqueID || from.Options.URURL != to.Options.URURL { | ||
s.timer.Reset(time.Duration(to.Options.URInitialDelayS) * time.Second) |
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.
I suspect this is a data race on s.timer
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.
Why? s.timer is not touched once it's initialized.
@st-review retest |
I'm sorry, @AudriusButkevicius. I'm afraid I don't know what you mean. I know how to |
@st-review rebuild |
It's used by Serve() and reset by the config commit.
On 10 Sep 2017, at 11:14, Audrius Butkevicius <notifications@github.com<mailto:notifications@github.com>> wrote:
@AudriusButkevicius commented on this pull request.
________________________________
In cmd/syncthing/usage_report.go<#4347 (comment)>:
}
}
}
+func (s *usageReportingService) VerifyConfiguration(from, to config.Configuration) error {
+ return nil
+}
+
+func (s *usageReportingService) CommitConfiguration(from, to config.Configuration) bool {
+ if from.Options.URAccepted != to.Options.URAccepted || from.Options.URUniqueID != to.Options.URUniqueID || from.Options.URURL != to.Options.URURL {
+ s.timer.Reset(time.Duration(to.Options.URInitialDelayS) * time.Second)
Why? s.timer is not touched once it's initialized.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#4347 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AAHp8vHHMz3BSpM9p5JX3uLxf00cg4CYks5sg6hZgaJpZM4PLMOK>.
|
Sure but that's just reads, which means it should be fine? |
It's not, but don't take my word for it package main
import (
"fmt"
"testing"
"time"
)
func TestTimer(t *testing.T) {
test := &test{
t: time.NewTimer(0),
}
go test.Serve()
for i := 0; i < 5; i++ {
test.Commit()
time.Sleep(time.Second)
}
}
type test struct {
t *time.Timer
}
func (t *test) Serve() {
t.t.Reset(0)
for {
<-t.t.C
fmt.Println("tick")
t.t.Reset(time.Second)
}
}
func (t *test) Commit() {
fmt.Println("resetting timer")
t.t.Reset(10 * time.Millisecond)
}
|
Is that a race internally setting something in the timer or accessing the timer in general. |
I think it's just the Reset() that does internal unlocked writes, so protecting that should be enough. There's a whole discussion in the Reset() documentation that says you can't do Reset() concurrently with the channel read, but I think that is for correctness and not relevant as we don't really care if the timer fires at exactly the same time we call Reset(). (That stuff matters if the timer represents a timeout error that should not fire in case of Reset() etc but we don't care.) The race detector should tell us if it's otherwise. |
Anyway, this uses a channel now. |
if ($scope.system && $scope.config.options.urSeen < $scope.system.urVersionMax) { | ||
// Usage reporting format has changed, prompt the user to re-accept. | ||
$('#ur').modal(); | ||
} |
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.
This is a bit racy, as we rely on $scope.system being populated first to actually do the prompt.
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.
Otherwise lgtm
@@ -6,7 +6,7 @@ | |||
<p translate>The aggregated statistics are publicly available at the URL below.</p> | |||
<p><a href="https://data.syncthing.net/" target="_blank">https://data.syncthing.net/</a></p> | |||
<label translate>Version</label> | |||
<select class="form-control" ng-model="reportDataPreviewVersion" ng-change="refreshReportDataPreview()"> | |||
<select id="urPreviewVersion" class="form-control" ng-model="$parent.$parent.reportDataPreviewVersion" ng-change="refreshReportDataPreview()" > |
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.
... 😷
cmd/syncthing/usage_report.go
Outdated
@@ -234,13 +234,14 @@ func (s *usageReportingService) sendUsageReport() error { | |||
|
|||
func (s *usageReportingService) Serve() { | |||
s.stop = make(chan struct{}) | |||
s.timer.Reset(time.Duration(s.cfg.Options().URInitialDelayS) * time.Second) | |||
|
|||
t := time.NewTimer(time.Duration(s.cfg.Options().URInitialDelayS) * time.Second) |
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.
defer t.Stop()
@@ -133,7 +135,11 @@ angular.module('syncthing.core') | |||
}).error($scope.emitHTTPError); | |||
|
|||
$http.get(urlbase + '/svc/report').success(function (data) { | |||
$scope.reportData = data; | |||
$scope.reportDataPreview = $scope.reportData = data; | |||
if ($scope.system && $scope.config.options.urSeen < $scope.system.urVersionMax) { |
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.
This might not work for candidate releases. For those we set urAccepted = urVersionMax
(or the equivalent what the variables are a called) on startup, but we don't tweak urSeen
so this dialog would be triggered unnecessarily.
Updated and added usage stats for features of the ignore patterns. |
lib/model/model.go
Outdated
} | ||
|
||
// Noops, remove | ||
if strings.HasPrefix(line, "**") { |
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.
I don't think doube star prefixes are noops, e.g. **/temp
isn't rooted, is it?
I need to remove **/ I guess as that is equivalent behaviour without the prefix. |
80e75f3
to
62f6b86
Compare
@st-review rebuild |
This is good to go I think? |
Yes |
@st-review merge |
👌 Merged as 2760d03. Thanks, @AudriusButkevicius! |
I assume this need schema changes in the db? |
Yes, it needs handling on the receiving side. I think we have a couple of migrations in that code already, basically |
I guess if you're looking at a new challenge maybe refactor it to use a json document type in the database so that we'd just need to hack the various analytics parts in the future and not the whole storage part |
Tested manually.
Not sure if we need to bump the version here.