LEVELDB's manifest file

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

From this article began to want to write leveldb of small knowledge. Understand the manifest file first, because this file is related to the read of the instance. As for the internal structure of the document and how it came, we'll talk about it later.

if instances[Name], err = leveldb.OpenFile(Dir, instance); err != nil {        return errors.New(fmt.Sprintf(`leveldbs: err while open %s : %s`, Dir, err.Error()))}

This code in the case of manifest file corruption will appear error, error content:

ERROR leveldb: manifest corrupted: missing [file=MANIFEST-*******]

Cause of error: Leveldb may cause manifest file to be damaged or lost due to some other reasons causing the program to drop abruptly during the stored procedure. This can only be done manually repair , cannot open the one there is instance no way to execute the get command. repairBusiness party code can be written in this way, which is Golang illustrated in code:

if instances[cfgIns.Name], err = leveldb.OpenFile(Dir, instance); err != nil {    if instances[cfgIns.Name], err = leveldb.RecoverFile(Dir, instance); err != nil {        return errors.New(fmt.Sprintf(`err while recoverfile%s : %s`, Dir, err.Error()))    }}

RecoverFileThe source code for this API function is:

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}

Manifest file corruption or lost repair is quite simple, it means that Google's great God had thought of these things. Through the above example first feel the existence of the next manifest file, below we learn the manifest file structure and the origin of the file. File structure

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.