MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / TakeDbOnline

Method TakeDbOnline

rest/server_context.go:1482–1509  ·  view source on GitHub ↗
(nonContextStruct base.NonCancellableContext, database *db.DatabaseContext)

Source from the content-addressed store, hash-verified

1480}
1481
1482func (sc *ServerContext) TakeDbOnline(nonContextStruct base.NonCancellableContext, database *db.DatabaseContext) {
1483
1484 // Take a write lock on the Database context, so that we can cycle the underlying Database
1485 // without any other call running concurrently
1486 database.AccessLock.Lock()
1487 defer database.AccessLock.Unlock()
1488
1489 // We can only transition to Online from Offline state
1490 if atomic.CompareAndSwapUint32(&database.State, db.DBOffline, db.DBStarting) {
1491 reloadedDb, err := sc.ReloadDatabase(nonContextStruct.Ctx, database.Name, true)
1492 if err != nil {
1493 base.ErrorfCtx(nonContextStruct.Ctx, "Error reloading database from config: %v", err)
1494 return
1495 }
1496
1497 if len(reloadedDb.RequireResync) > 0 {
1498 base.ErrorfCtx(nonContextStruct.Ctx, "Database has collections that require regenerate_sequences resync before it can go online: %v", reloadedDb.RequireResync)
1499 return
1500 }
1501 // Reloaded DB should already be online in most cases, but force state to online to handle cases
1502 // where config specifies offline startup
1503 atomic.StoreUint32(&reloadedDb.State, db.DBOnline)
1504
1505 } else {
1506 base.InfofCtx(nonContextStruct.Ctx, base.KeyCRUD, "Unable to take Database : %v online , database must be in Offline state", base.UD(database.Name))
1507 }
1508
1509}
1510
1511// validateMetadataStore will
1512func validateMetadataStore(ctx context.Context, metadataStore base.DataStore) error {

Callers 3

handleDbOnlineMethod · 0.45
TestResyncLegacyRevFunction · 0.45

Calls 6

ReloadDatabaseMethod · 0.95
ErrorfCtxFunction · 0.92
InfofCtxFunction · 0.92
UDFunction · 0.92
LockMethod · 0.45
UnlockMethod · 0.45

Tested by 2

TestResyncLegacyRevFunction · 0.36