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

Bugfix/bisect git race detector test #1360

Closed
wants to merge 6 commits into from
Closed
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
18 changes: 16 additions & 2 deletions core/services/synchronization/stats_pusher.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"net/url"
"sync"
"time"

"github.com/jinzhu/gorm"
Expand Down Expand Up @@ -54,8 +55,10 @@ func NewStatsPusher(orm *orm.ORM, url *url.URL, accessKey, secret string, afters

if url != nil {
sp.WSClient = NewWebSocketClient(url, accessKey, secret)
gormCallbacksMutex.Lock()
orm.DB.Callback().Create().Register(createCallbackName, createSyncEventWithStatsPusher(sp))
orm.DB.Callback().Update().Register(updateCallbackName, createSyncEventWithStatsPusher(sp))
gormCallbacksMutex.Unlock()
}
return sp
}
Expand All @@ -77,8 +80,11 @@ func (sp *StatsPusher) Close() error {
if sp.cancel != nil {
sp.cancel()
}
sp.ORM.DB.Callback().Create().Remove(createCallbackName)
sp.ORM.DB.Callback().Update().Remove(updateCallbackName)
gormCallbacksMutex.Lock()
callbacks := sp.ORM.DB.Callback()
callbacks.Create().Remove(createCallbackName)
callbacks.Update().Remove(updateCallbackName)
gormCallbacksMutex.Unlock()
return sp.WSClient.Close()
}

Expand Down Expand Up @@ -211,3 +217,11 @@ func createSyncEventWithStatsPusher(sp *StatsPusher) func(*gorm.Scope) {
sp.PushNow()
}
}

var (
gormCallbacksMutex *sync.Mutex
)

func init() {
gormCallbacksMutex = new(sync.Mutex)
}
4 changes: 2 additions & 2 deletions core/store/migrations/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import (
// Migrate iterates through available migrations, running and tracking
// migrations that have not been run.
func Migrate(db *gorm.DB) error {
options := gormigrate.DefaultOptions
options := *gormigrate.DefaultOptions
options.UseTransaction = true

m := gormigrate.New(db, options, []*gormigrate.Migration{
m := gormigrate.New(db, &options, []*gormigrate.Migration{
{
ID: "0",
Migrate: migration0.Migrate,
Expand Down
5 changes: 1 addition & 4 deletions tools/ci/gorace_test
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#!/bin/bash

set -e

# Split up each test run to mitigate memory consumption
go test -race -cpu 2 -parallel 1 github.com/smartcontractkit/chainlink/core/internal && \
go test -race -cpu 2 -parallel 1 github.com/smartcontractkit/chainlink/core/services
GORACE="halt_on_error=1" go test -v -race -parallel 2 -p 1 github.com/smartcontractkit/chainlink/core/internal github.com/smartcontractkit/chainlink/core/services