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

Fix panic when SchemaRefreshInterval is 0 #187

Merged
merged 3 commits into from
Jan 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ func ConfigureLogger(conf Logger) {
conf.OutputFile, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666,
)
if err != nil {
log.Error("Can't open log output", "output", conf.OutputFile)
log.Errorf("Can't open log output file: %s", conf.OutputFile)
} else {
log.SetOutput(logFile)
}
Expand Down
16 changes: 8 additions & 8 deletions conformance/tests/ot_aggregations.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ def test_traversal_term_aggregation(O):

count += 1
if len(row["buckets"]) != 3:
errors.append(
"Unexpected number of terms: %d != %d" %
(len(row["buckets"]), 3)
)
errors.append(
"Unexpected number of terms: %d != %d" %
(len(row["buckets"]), 3)
)

for res in row["buckets"]:
if res["key"] == "alex":
Expand Down Expand Up @@ -83,10 +83,10 @@ def test_traversal_histogram_aggregation(O):
row = row['traversal-agg']

if len(row["buckets"]) < 3:
errors.append(
"Unexpected number of terms: %d != %d" %
(len(row["buckets"]), 3)
)
errors.append(
"Unexpected number of terms: %d != %d" %
(len(row["buckets"]), 3)
)

for res in row["buckets"]:
if res["key"] == 25:
Expand Down
28 changes: 14 additions & 14 deletions server/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,23 +422,23 @@ func (server *GripServer) cacheSchemas(ctx context.Context) {
if server.db == nil {
return
}
ticker := time.NewTicker(time.Duration(server.conf.SchemaRefreshInterval))
go func() {

if time.Duration(server.conf.SchemaRefreshInterval) == 0 {
server.buildSchemas(ctx)
if time.Duration(server.conf.SchemaRefreshInterval) == 0 {
return
}

ticker := time.NewTicker(time.Duration(server.conf.SchemaRefreshInterval))
server.buildSchemas(ctx)
for {
select {
case <-ctx.Done():
ticker.Stop()
return
case <-ticker.C:
server.buildSchemas(ctx)
}
for {
select {
case <-ctx.Done():
ticker.Stop()
return
case <-ticker.C:
server.buildSchemas(ctx)
}
}
}()
return
}
}

// GetSchema returns the schema of a specific graph in the database
Expand Down