Skip to content

Commit f505fa7

Browse files
committed
CBG-5168 don't panic when db is offline
1 parent b111d34 commit f505fa7

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

db/database.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,7 @@ func NewDatabaseContext(ctx context.Context, dbName string, bucket base.Bucket,
596596
}
597597

598598
dbContext.ResyncManager = NewResyncManagerDCP(metadataStore, dbContext.UseXattrs(), metaKeys)
599+
dbContext.AsyncIndexInitManager = NewAsyncIndexInitManager(dbContext.MetadataStore, dbContext.MetadataKeys)
599600

600601
return dbContext, nil
601602
}
@@ -2455,7 +2456,6 @@ func (db *DatabaseContext) StartOnlineProcesses(ctx context.Context) (returnedEr
24552456

24562457
db.TombstoneCompactionManager = NewTombstoneCompactionManager()
24572458
db.AttachmentCompactionManager = NewAttachmentCompactionManager(db.MetadataStore, db.MetadataKeys)
2458-
db.AsyncIndexInitManager = NewAsyncIndexInitManager(db.MetadataStore, db.MetadataKeys)
24592459

24602460
db.startReplications(ctx)
24612461

rest/indextest/index_init_api_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,12 +274,12 @@ func TestChangeIndexPartitionsDbOffline(t *testing.T) {
274274
t.Skip("This test only works against Couchbase Server with GSI enabled")
275275
}
276276

277-
// requires index init
278-
279-
rt := rest.NewRestTester(t, nil)
277+
rt := rest.NewRestTesterPersistentConfigNoDB(t)
280278
defer rt.Close()
281279

282-
rt.TakeDbOffline()
280+
dbConfig := rt.NewDbConfig()
281+
dbConfig.StartOffline = base.Ptr(true)
282+
rest.RequireStatus(t, rt.CreateDatabase("db", dbConfig), http.StatusCreated)
283283

284284
resp := rt.SendAdminRequest(http.MethodPost, "/{{.db}}/_index_init", `{"num_partitions":2}`)
285285
rest.RequireStatus(t, resp, http.StatusOK)

0 commit comments

Comments
 (0)