(ctx context.Context, dbName string)
| 1729 | } |
| 1730 | |
| 1731 | func (sc *ServerContext) _unsuspendDatabase(ctx context.Context, dbName string) (*db.DatabaseContext, error) { |
| 1732 | dbCtx := sc._databases[dbName] |
| 1733 | if dbCtx != nil { |
| 1734 | return dbCtx, nil |
| 1735 | } |
| 1736 | |
| 1737 | // Check if database is in dbConfigs so no need to search through buckets |
| 1738 | if dbConfig, ok := sc._dbConfigs[dbName]; ok { |
| 1739 | if !dbConfig.isSuspended { |
| 1740 | base.WarnfCtx(ctx, "attempting to unsuspend database %q that is not suspended", base.MD(dbName)) |
| 1741 | } |
| 1742 | if !base.ValDefault(dbConfig.Suspendable, sc.Config.IsServerless()) { |
| 1743 | base.InfofCtx(ctx, base.KeyAll, "attempting to unsuspend db %q while not configured to be suspendable", base.MD(dbName)) |
| 1744 | } |
| 1745 | |
| 1746 | bucket := dbName |
| 1747 | if dbConfig.Bucket != nil { |
| 1748 | bucket = *dbConfig.Bucket |
| 1749 | } |
| 1750 | |
| 1751 | cas, err := sc.BootstrapContext.GetConfig(ctx, bucket, sc.Config.Bootstrap.ConfigGroupID, dbName, &dbConfig.DatabaseConfig) |
| 1752 | if err == base.ErrNotFound { |
| 1753 | // Database no longer exists, so clean up dbConfigs |
| 1754 | base.InfofCtx(ctx, base.KeyConfig, "Database %q has been removed while suspended from bucket %q", base.MD(dbName), base.MD(bucket)) |
| 1755 | delete(sc._dbConfigs, dbName) |
| 1756 | return nil, err |
| 1757 | } else if err != nil { |
| 1758 | return nil, fmt.Errorf("unsuspending db %q failed due to an error while trying to retrieve latest config from bucket %q: %w", base.MD(dbName).Redact(), base.MD(bucket).Redact(), err) |
| 1759 | } |
| 1760 | dbConfig.cfgCas = cas |
| 1761 | failFast := false |
| 1762 | dbCtx, err = sc._getOrAddDatabaseFromConfig(ctx, dbConfig.DatabaseConfig, getOrAddDatabaseConfigOptions{ |
| 1763 | useExisting: false, |
| 1764 | failFast: failFast, |
| 1765 | }) |
| 1766 | if err != nil { |
| 1767 | return nil, err |
| 1768 | } |
| 1769 | return dbCtx, nil |
| 1770 | } |
| 1771 | |
| 1772 | return nil, base.ErrNotFound |
| 1773 | } |
| 1774 | |
| 1775 | // ////// STATS LOGGING |
| 1776 |
no test coverage detected