Skip to content

add_index() does not use locking #45

@cc32d9

Description

@cc32d9

I'm using chainbase in Chronicle project in concurrent mode: one process opens the database in read-write mode and is constantly updating it as state history data arrives. Then, multiple read-only processes read from the same shared memory.

I define CHAINBASE_CHECK_LOCKING globally.

I get the following error when read-only client opens the database and defines the indexes:

May 25 01:05:46 sthist chronicle-receiver[5523]: warn  2019-05-25T01:05:46.141 chronicle receiver_plugin.cpp:1201      plugin_initialize    ] 13 N5boost16exception_detail10clone_implINS0_19error_info_injectorISt11logic_errorEEEE: existing index for chronicle::received_block_object has an undo stack (revision range [-1, 23598015]) that is inconsistent with other indices in the database (revision range [23597735, 23597736]); corrupted database?
May 25 01:05:46 sthist chronicle-receiver[5523]: rethrow existing index for chronicle::received_block_object has an undo stack (revision range [-1, 23598015]) that is inconsistent with other indices in the database (revision range [23597735, 23597736]); corrupted database?:
May 25 01:05:46 sthist chronicle-receiver[5523]:     {"what":"existing index for chronicle::received_block_object has an undo stack (revision range [-1, 23598015]) that is inconsistent with other indices in the database (revision range [23597735, 23597736]); corrupted database?"}
May 25 01:05:46 sthist chronicle-receiver[5523]:     chronicle-recei  receiver_plugin.cpp:1201 plugin_initialize

so, there should be a global lock wrapping around add_index(). For now I will wrap the locks around calling add_index in my program, but I think it makes sense to protect it inside chainbase.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions