Boltdb Source Analysis-Start and initialize-2

Source: Internet
Author: User
This is a created article in which the information may have evolved or changed.

Boltdb Startup and initialization

Based on the previous summary, boltdb only a single file is used for persistence, and at boltdb startup, the corresponding persistence file is opened, and then the file lock is obtained based on whether it is read-only mode. When it is not read-only, boltdb an exclusive file lock is used to ensure that only one process can manipulate the file, preventing multiple processes from operating simultaneously, resulting in data corruption.

When the persisted file size is 0 o'clock, boltdb the database is considered to be newly created, then initialized (writing 4 initial page), then the file is mapped to memory space and finally read from the mapped memory, meta0 meta1 data.

The Freelist pgid data is then read from the current Freelist page identified in the meta data, and the free page cache is then freelist based on that data. That is, a map is used to record which page is free.

This completes the startup and initialization.

Because the boltdb key-value operation is updated directly through the B-tree index, the data is written directly to the specified file page, so there is only one write and no log to maintain boltdb the crash consistency.

Related Article

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.