| 234 | } |
| 235 | |
| 236 | func (s *Store) Close(ctx context.Context) (err error) { |
| 237 | s.mu.Lock() |
| 238 | dbs := slices.Clone(s.dbs) |
| 239 | s.mu.Unlock() |
| 240 | |
| 241 | for _, db := range dbs { |
| 242 | if e := db.Close(ctx); e != nil { |
| 243 | if errors.Is(e, ErrShutdownInterrupted) { |
| 244 | if err == nil { |
| 245 | err = e |
| 246 | } |
| 247 | } else if err == nil || errors.Is(err, ErrShutdownInterrupted) { |
| 248 | err = e |
| 249 | } |
| 250 | } |
| 251 | } |
| 252 | |
| 253 | // Cancel and wait for background tasks to complete. |
| 254 | s.cancel() |
| 255 | s.wg.Wait() |
| 256 | |
| 257 | return err |
| 258 | } |
| 259 | |
| 260 | func (s *Store) DBs() []*DB { |
| 261 | s.mu.Lock() |