File tree Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -150,6 +150,16 @@ func OpenDB(path string) *DB {
150
150
// discover is a helper function to discover and initialize all existing bitcask stores at the path.
151
151
// caller must hold write lock.
152
152
func (db * DB ) discover () ([]string , error ) {
153
+ if db .initialized .Load () {
154
+ stores := make ([]string , 0 , len (db .store ))
155
+ for store := range db .store {
156
+ if store == "" {
157
+ continue
158
+ }
159
+ stores = append (stores , store )
160
+ }
161
+ return stores , nil
162
+ }
153
163
stores := make ([]string , 0 , len (db .store ))
154
164
errs := make ([]error , 0 , len (db .store ))
155
165
if db .store == nil {
@@ -510,8 +520,11 @@ func (db *DB) CloseAll() error {
510
520
}
511
521
func (db * DB ) addAllStoresToMeta () {
512
522
storeMap := db .allStores ()
513
- storeNames := make ([]string , len (storeMap ))
523
+ storeNames := make ([]string , 0 , len (storeMap ))
514
524
for name := range storeMap {
525
+ if name == "" {
526
+ continue
527
+ }
515
528
storeNames = append (storeNames , name )
516
529
}
517
530
db .meta = db .meta .WithStores (storeNames ... )
Original file line number Diff line number Diff line change @@ -547,8 +547,11 @@ func (db *DB) allMetrics() map[string]*pogreb.Metrics {
547
547
548
548
func (db * DB ) addAllStoresToMeta () {
549
549
storeMap := db .allStores ()
550
- storeNames := make ([]string , len (storeMap ))
550
+ storeNames := make ([]string , 0 , len (storeMap ))
551
551
for name := range storeMap {
552
+ if name == "" {
553
+ continue
554
+ }
552
555
storeNames = append (storeNames , name )
553
556
}
554
557
db .meta = db .meta .WithStores (storeNames ... )
@@ -570,6 +573,16 @@ func (db *DB) SyncAll() error {
570
573
}
571
574
572
575
func (db * DB ) discover () ([]string , error ) {
576
+ if db .initialized .Load () {
577
+ stores := make ([]string , 0 , len (db .store ))
578
+ for name := range db .store {
579
+ if name == "" {
580
+ continue
581
+ }
582
+ stores = append (stores , name )
583
+ }
584
+ return stores , nil
585
+ }
573
586
stores := make ([]string , 0 )
574
587
errs := make ([]error , 0 )
575
588
if db .store == nil {
You can’t perform that action at this time.
0 commit comments