Skip to content

IntraL0Compaction cause consitency corruption #5913

@Little-Wallace

Description

@Little-Wallace

Note: Please use Issues only for bug reports. For questions, discussions, feature requests, etc. post to dev group: https://www.facebook.com/groups/rocksdb.dev

Expected behavior

Actual behavior

We use RocksDB as storage library of TiKV, and we set force_consistency_checks be true in product environment. It crash because of CheckConsistency failed. The error is "L0 files seqno 3001491972 3004797440 vs. 3002875611 3004524421". The message appeared many times in stderr.

By the way, we set WriteOptions.sync be false. I'm not sure whether it was related to this problem.

This is our RocksDB Branch and RocksDB Version

Steps to reproduce the behavior

We have reproduce this problem.
And there is my code: https://github.com/Little-Wallace/rocksdb/blob/l0-check/db/db_compaction_test.cc#L4759

This problem is caused by IntraL0Compaction.

  • First we ingest five external sst into Rocksdb, and they happened to be ingested in L0. and there had been some data in memtable, which make the smallest sequence number of memtable is less than which of sst that we ingest.

  • If there had been one compaction job which compacted sst from L0 to L1, LevelCompactionPicker would trigger a IntraL0Compaction which would compact this five sst from L0 to L0. We call this sst A, which was merged from five ingested sst.

  • Then some data was put into memtable, and memtable was flushed to L0. We called this sst B.

  • RocksDB check consistency , and find the smallest_seqno of A is less than that of B and crash. Because B was merged from five sst, the smallest sequence number of it was less than the biggest sequece number of it. So RocksDB could not tell if B was produce by ingested.

Metadata

Metadata

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