func RecoverFile(path string, o *opt.Options) (db *DB, err error) {
	stor, err := storage.OpenFile(path)
	if err != nil {
		return
	}
	db, err = Recover(stor, o)
	if err != nil {
		stor.Close()
	} else {
		db.closer = stor
	}
	return
}
RecoverFile recovers and opens a DB with missing or corrupted manifest files
for the given path. It will ignore any manifest files, valid or not.
The DB must already exist or it will returns an error.
Also, Recover will ignore ErrorIfMissing and ErrorIfExist options.

RecoverFile uses standard file-system backed storage implementation as desribed
in the leveldb/storage package.

The returned DB instance is goroutine-safe.
The DB must be closed after use, by calling Close method.
package leveldb
import (
	"container/list"
	"fmt"
	"io"
	"os"
	"runtime"
	"strings"
	"sync"
	"sync/atomic"
	"time"
	"github.com/syndtr/goleveldb/leveldb/errors"
	"github.com/syndtr/goleveldb/leveldb/iterator"
	"github.com/syndtr/goleveldb/leveldb/journal"
	"github.com/syndtr/goleveldb/leveldb/memdb"
	"github.com/syndtr/goleveldb/leveldb/opt"
	"github.com/syndtr/goleveldb/leveldb/storage"
	"github.com/syndtr/goleveldb/leveldb/table"
	"github.com/syndtr/goleveldb/leveldb/util"
)
type DB struct {
	seq uint64
	s *session
	memMu             sync.RWMutex
	memPool           chan *memdb.DB
	mem, frozenMem    *memDB
	journal           *journal.Writer
	journalWriter     storage.Writer
	journalFile       storage.File
	frozenJournalFile storage.File
	frozenSeq         uint64
	snapsMu   sync.Mutex
	snapsList *list.List
	aliveSnaps, aliveIters int32
	writeC       chan *Batch
	writeMergedC chan bool
	writeLockC   chan struct{}
	writeAckC    chan error
	writeDelay   time.Duration
	writeDelayN  int
	journalC     chan *Batch
	journalAckC  chan error
	tcompCmdC        chan cCmd
	tcompPauseC      chan chan<- struct{}
	mcompCmdC        chan cCmd
	compErrC         chan error
	compPerErrC      chan error
	compErrSetC      chan error
	compWriteLocking bool
	compStats        []cStats
	closeW sync.WaitGroup
	closeC chan struct{}
	closed uint32
	closer io.Closer
}
func openDB(s *session) (*DB, error) {
	s.log("db@open opening")
	start := time.Now()
	db := &DB{
		s: s,
		seq: s.stSeqNum,
		memPool: make(chan *memdb.DB, 1),
		snapsList: list.New(),
		writeC:       make(chan *Batch),
		writeMergedC: make(chan bool),
		writeLockC:   make(chan struct{}, 1),
		writeAckC:    make(chan error),
		journalC:     make(chan *Batch),
		journalAckC:  make(chan error),
		tcompCmdC:   make(chan cCmd),
		tcompPauseC: make(chan chan<- struct{}),
		mcompCmdC:   make(chan cCmd),
		compErrC:    make(chan error),
		compPerErrC: make(chan error),
		compErrSetC: make(chan error),
		compStats:   make([]cStats, s.o.GetNumLevel()),
		closeC: make(chan struct{}),
	}
	readOnly := s.o.GetReadOnly()
	if readOnly {
		if err := db.recoverJournalRO(); err != nil {
			return nil, err
		}
	} else {
		if err := db.recoverJournal(); err != nil {
			return nil, err
		}
		if err := db.checkAndCleanFiles(); err != nil {
			if db.journal != nil {
				db.journal.Close()
				db.journalWriter.Close()
			}
			return nil, err
		}
	}
	go db.compactionError()
	go db.mpoolDrain()
	if readOnly {
		db.SetReadOnly()
	} else {
		db.closeW.Add(3)
		go db.tCompaction()
		go db.mCompaction()
		go db.jWriter()
	}
	s.logf("db@open done T·%v", time.Since(start))
	runtime.SetFinalizer(db, (*DB).Close)
	return db, nil
}
func Open(stor storage.Storage, o *opt.Options) (db *DB, err error) {
	s, err := newSession(stor, o)
	if err != nil {
		return
	}
	defer func() {
		if err != nil {
			s.close()
			s.release()
		}
	}()
	err = s.recover()
	if err != nil {
		if !os.IsNotExist(err) || s.o.GetErrorIfMissing() {
			return
		}
		err = s.create()
		if err != nil {
			return
		}
	} else if s.o.GetErrorIfExist() {
		err = os.ErrExist
		return
	}
	return openDB(s)
}
func OpenFile(path string, o *opt.Options) (db *DB, err error) {
	stor, err := storage.OpenFile(path)
	if err != nil {
		return
	}
	db, err = Open(stor, o)
	if err != nil {
		stor.Close()
	} else {
		db.closer = stor
	}
	return
}
func Recover(stor storage.Storage, o *opt.Options) (db *DB, err error) {
	s, err := newSession(stor, o)
	if err != nil {
		return
	}
	defer func() {
		if err != nil {
			s.close()
			s.release()
		}
	}()
	err = recoverTable(s, o)
	if err != nil {
		return
	}
	return openDB(s)
}