From 34fb454496d7153023014661f9a6a1e0e155eeae Mon Sep 17 00:00:00 2001 From: Nathan Ollerenshaw Date: Fri, 4 Aug 2017 22:00:45 -0700 Subject: [PATCH 1/2] Added warning message to the lockfile waiting routine so that if we are waiting for something, we at least print a message to stderr about it. Hopefully will make situations like what is described in #947 obvious. --- internal/gps/source_manager.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/internal/gps/source_manager.go b/internal/gps/source_manager.go index b009610456..62637cc456 100644 --- a/internal/gps/source_manager.go +++ b/internal/gps/source_manager.go @@ -188,11 +188,24 @@ func NewSourceManager(cachedir string) (*SourceMgr, error) { // If it's a TemporaryError, we retry every second. Otherwise, we fail // permanently. // - // TODO: After some time, we should emit some kind of warning that we're waiting - // for the lockfile to be released. #534 should be address before we will do that. + // TODO: #534 needs to be implemented to provide a better way to log warnings, + // but until then we will just use stderr. + // + // #947 appears to be caused by some locking issue; as this is the most likely + // culprit, we will add some warnings here, so every 15 seconds we will emit + // a warning to stderr that we're waiting for the lockfile. + lasttime := time.Now() err = lockfile.TryLock() for err != nil { + nowtime := time.Now() + duration := nowtime.Sub(lasttime) + + if duration > 15*time.Second { + fmt.Fprintf(os.Stderr, "waiting for lockfile %s: %s\n", glpath, err.Error()) + lasttime = nowtime + } + if _, ok := err.(interface { Temporary() bool }); ok { From 977e7812464fcdb1f2afda6fc837574f0753d5aa Mon Sep 17 00:00:00 2001 From: Nathan Ollerenshaw Date: Sun, 6 Aug 2017 08:02:21 -0700 Subject: [PATCH 2/2] Removed spurious comment. Added spurious comment. Modified logic to display warning initially, and then every 15 seconds, when lockfile busy. --- internal/gps/source_manager.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/gps/source_manager.go b/internal/gps/source_manager.go index 62637cc456..d9283162ce 100644 --- a/internal/gps/source_manager.go +++ b/internal/gps/source_manager.go @@ -190,17 +190,17 @@ func NewSourceManager(cachedir string) (*SourceMgr, error) { // // TODO: #534 needs to be implemented to provide a better way to log warnings, // but until then we will just use stderr. - // - // #947 appears to be caused by some locking issue; as this is the most likely - // culprit, we will add some warnings here, so every 15 seconds we will emit - // a warning to stderr that we're waiting for the lockfile. - lasttime := time.Now() + // Implicit Time of 0. + var lasttime time.Time err = lockfile.TryLock() for err != nil { nowtime := time.Now() duration := nowtime.Sub(lasttime) + // The first time this is evaluated, duration will be very large as lasttime is 0. + // Unless time travel is invented and someone travels back to the year 1, we should + // be ok. if duration > 15*time.Second { fmt.Fprintf(os.Stderr, "waiting for lockfile %s: %s\n", glpath, err.Error()) lasttime = nowtime