Skip to content

the concurrency problem of the compaction process and the regular write process #3604

@1559924775

Description

@1559924775

BUG REPORT

Describe the bug

we use SortedLedgerStorage+EntryLogManagerForSingleEntryLog.
When the entrylog file managed by EntryLogManagerForSingleEntryLog reaches the upper limit, the createNewLog method is executed. This operation is not locked, which will conflict with the addEntry executed in the compaction process, resulting in disordered entryLog file data.
14e56f8a3e057508f446abb1ccd7b687
ae141da9c0fa6d51373775c19e0860ad
There is a concurrency problem with the two operations shown above.
In our case we found this code execution order:
1.logChannel.flush();
2.logChannel.write(sizeBuffer);
3.logChannel.appendLedgersMap();
4.logChannel.write(entry);

The correct entryLog file format should be like this:
header
entrySize1+ledgerId1+entryData1
entrySize2+ledgerId2+entryData2
...
entrySizen+ledgerIdn+entryDatan
ledgersMap

The wrong entrylog is as follows:
header
entrySize1+ledgerId1+entryData1
entrySize2+ledgerId2+entryData2
...
entrySizen
ledgersMap
ledgerIdn+entryDatan

I used the scanEntryLog method in EntryLogger to parse an error file. The phenomenon is as follows:
image
image

@hangc0276

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions