summaryrefslogtreecommitdiffstats
path: root/modules/indexer
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2020-02-28 22:00:09 +0000
committerGitHub <noreply@github.com>2020-02-28 22:00:09 +0000
commitc32f3da33c38e18a7ed4a8c49de27898c2aa07f8 (patch)
tree8b9454925b3095126ef4617cf2999b024aae9b6d /modules/indexer
parent154b137b6d97e11c3d52d3b5844d61f8f14d26b9 (diff)
downloadgitea-c32f3da33c38e18a7ed4a8c49de27898c2aa07f8.tar.gz
gitea-c32f3da33c38e18a7ed4a8c49de27898c2aa07f8.zip
Handle panic in indexer initialisation better (#10534)
* Handle panic in indexer initialisation better * as per @guillep2k
Diffstat (limited to 'modules/indexer')
-rw-r--r--modules/indexer/code/indexer.go11
-rw-r--r--modules/indexer/issues/indexer.go8
2 files changed, 19 insertions, 0 deletions
diff --git a/modules/indexer/code/indexer.go b/modules/indexer/code/indexer.go
index 6cbda1491b..3e90f769df 100644
--- a/modules/indexer/code/indexer.go
+++ b/modules/indexer/code/indexer.go
@@ -64,6 +64,17 @@ func Init() {
go func() {
start := time.Now()
log.Info("PID: %d Initializing Repository Indexer at: %s", os.Getpid(), setting.Indexer.RepoPath)
+ defer func() {
+ if err := recover(); err != nil {
+ log.Error("PANIC whilst initializing repository indexer: %v\nStacktrace: %s", err, log.Stack(2))
+ log.Error("The indexer files are likely corrupted and may need to be deleted")
+ log.Error("You can completely remove the \"%s\" directory to make Gitea recreate the indexes", setting.Indexer.RepoPath)
+ cancel()
+ indexer.Close()
+ close(waitChannel)
+ log.Fatal("PID: %d Unable to initialize the Repository Indexer at path: %s Error: %v", os.Getpid(), setting.Indexer.RepoPath, err)
+ }
+ }()
bleveIndexer, created, err := NewBleveIndexer(setting.Indexer.RepoPath)
if err != nil {
if bleveIndexer != nil {
diff --git a/modules/indexer/issues/indexer.go b/modules/indexer/issues/indexer.go
index d2233ac6a8..d2079e9dbf 100644
--- a/modules/indexer/issues/indexer.go
+++ b/modules/indexer/issues/indexer.go
@@ -143,6 +143,14 @@ func InitIssueIndexer(syncReindex bool) {
var populate bool
switch setting.Indexer.IssueType {
case "bleve":
+ defer func() {
+ if err := recover(); err != nil {
+ log.Error("PANIC whilst initializing issue indexer: %v\nStacktrace: %s", err, log.Stack(2))
+ log.Error("The indexer files are likely corrupted and may need to be deleted")
+ holder.cancel()
+ log.Fatal("PID: %d Unable to initialize the Bleve Issue Indexer at path: %s Error: %v", os.Getpid(), setting.Indexer.IssuePath, err)
+ }
+ }()
issueIndexer := NewBleveIndexer(setting.Indexer.IssuePath)
exist, err := issueIndexer.Init()
if err != nil {