Skip to content

Commit

Permalink
CBG-308 Recover on panic in SimpleChangesFeed goroutine (#4055)
Browse files Browse the repository at this point in the history
In the event of a panic, the feed generation goroutine in SimpleChangesFeed should only terminate the associated changes request, not Sync Gateway.
Backports CBG-308 to 2.1.3.1.
  • Loading branch information
adamcfraser committed Apr 6, 2019
1 parent 31bb22a commit 450a145
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion db/changes.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"encoding/json"
"errors"
"fmt"
"runtime/debug"
"sort"
"time"

Expand Down Expand Up @@ -357,7 +358,11 @@ func (db *Database) SimpleMultiChangesFeed(chans base.Set, options ChangesOption
base.StatsExpvars.Add("simpleChanges_total", 1)
base.StatsExpvars.Add("simpleChanges_active", 1)
defer func() {
base.Infof(base.KeyChanges, "MultiChangesFeed done %s", base.UD(to))
if panicked := recover(); panicked != nil {
base.Warnf(base.KeyChanges, "Unexpected panic sending changes - terminating changes: \n %s", panicked, debug.Stack())
} else {
base.Infof(base.KeyChanges, "MultiChangesFeed done %s", base.UD(to))
}
base.StatsExpvars.Add("simpleChanges_active", -1)
close(output)
}()
Expand Down

0 comments on commit 450a145

Please sign in to comment.