Skip to content

Database corruption on "No space left on device" #6316

Closed

Description

@koldat

Sometimes when there is out of disk space and database tries to add version_set the database is corrupted. When application is restarted it cannot recover (cannot load families list in listColumnFamilies).

Expected behavior

Database should not get to corrupted state.

Actual behavior

2020/01/02-16:46:09.515253 7fc85cd65700 EVENT_LOG_v1 {"time_micros": 1577983569515237, "job": 167277, "event": "table_file_deletion", "file_number": 2054}
2020/01/02-16:47:12.287459 7fc84d7ed700 [ERROR] [il/sst_file_manager_impl.cc:281] free space [1048576 bytes] is less than required disk buffer [33554432 bytes]
2020/01/02-16:47:12.287512 7fc84d7ed700 [ERROR] [il/sst_file_manager_impl.cc:282] Cannot clear hard error
2020/01/02-16:47:22.260302 7fc84d7ed700 [ERROR] [il/sst_file_manager_impl.cc:281] free space [1048576 bytes] is less than required disk buffer [33554432 bytes]
2020/01/02-16:47:22.260353 7fc84d7ed700 [ERROR] [il/sst_file_manager_impl.cc:282] Cannot clear hard error
2020/01/02-16:47:22.268201 7fc861ef9700 [ERROR] [/version_set.cc:3094] MANIFEST write IO error: No space left on deviceWhile fsync: ./data/tasdb/MANIFEST-013313: No space left on device
2020/01/02-16:47:22.288241 7fc861ef9700 [ERROR] [/version_set.cc:3188] Error in committing version edit to MANIFEST: 
VersionEdit {
  PrevLogNumber: 0
  NextFileNumber: 21472
  LastSeq: 296171228
  DeleteFile: 1 21425
  ColumnFamily: 9
}
2020/01/02-16:47:22.295837 7fc861ef9700 [ERROR] [/version_set.cc:3094] MANIFEST write IO error: No space left on deviceWhile fsync: ./data/tasdb/MANIFEST-013313: No space left on device
2020/01/02-16:47:22.296175 7fc861ef9700 [ERROR] [/version_set.cc:3188] Error in committing version edit to MANIFEST: 
VersionEdit {
  PrevLogNumber: 0
  NextFileNumber: 21472
  LastSeq: 296171228
  DeleteFile: 1 21426
  ColumnFamily: 10
}
2020/01/02-16:47:27.264532 7fc84d7ed700 [ERROR] [il/sst_file_manager_impl.cc:281] free space [1048576 bytes] is less than required disk buffer [33554432 bytes]
2020/01/02-16:47:27.264544 7fc84d7ed700 [ERROR] [il/sst_file_manager_impl.cc:282] Cannot clear hard error
2020/01/02-16:47:32.265158 7fc84d7ed700 [ERROR] [il/sst_file_manager_impl.cc:281] free space [1048576 bytes] is less than required disk buffer [33554432 bytes]
2020/01/02-16:47:32.265187 7fc84d7ed700 [ERROR] [il/sst_file_manager_impl.cc:282] Cannot clear h                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            

And then:

>ldb list_column_families .
Error in processing db . Corruption: error in middle of record

Steps to reproduce the behavior

Have writes to database with many families and cause out of disk space

Activity

  1. koldat commented on Jan 21, 2020

    @koldat
    ContributorAuthor

    @siying Do you know if there is some option to mitigate this? I have seen only manifest_preallocation_size and atomic_flush, but I am not sure if it can help. Maybe manifest_preallocation_size=0?

  2. siying commented on Jan 22, 2020

    @siying
    Contributor

    This is not expected and may indicate a failure somewhere. Do you know this error happens when reading manifest or WAL files? For latter, reducing recovery level should work. If it is manifest, we probably has a bug somewhere. You can try to truncate manifest file byte by byte until RocksDB can open the DB. CC oncall @maysamyabandeh

  3. koldat commented on Jan 22, 2020

    @koldat
    ContributorAuthor

    It is in reading manifest. Repairdb works, but I am afraid it does not need to be exactly same state of dB.

    The worst is that manifest is like 3.5mb big, but failure is somewhere in the middle. But maybe I misunderstood the file offsets of reader. It looks like write fails, but is starts writing after some time space is available. I know dB is in no write state when there is out of disk, but manifest code does not look to me it follows that. There is some queue that tries to write version sets without check. But honestly I do not understand these core data flows, so I can be completely wrong.

    It happened twice already in two completely different run environments. Unfortunately contains sensitive data (keys of sst) so cannot share.

    The process was also running very long time after write failure. Administrators during that time added some space. And then restarted process. Maybe it can also be the case.

  4. siying commented on Jan 22, 2020

    @siying
    Contributor

    @anand1976 I remember we never handle any manifest writing failure, is it correct?

  5. anand1976 commented on Jan 22, 2020

    @anand1976
    Contributor

    @siying I think the bug here is that when the DB recovers from NoSpace error, it continues to append to the current manifest. We should create a new manifest file if the previous append/sync failed.

  6. siying commented on Jan 24, 2020

    @siying
    Contributor

    @anand1976 for now, can we fail the resume if the write failure happens in manifest? It seems to be a serious bug and we need to fix it.

  7. anand1976 commented on Jan 24, 2020

    @anand1976
    Contributor

    @siying I created a PR to fix this, #6331 . Let me know what you think. It feels more straightforward to just force the creation of a new manifest file if we couldn't append to the current one. This will also take care of other cases where we append to the manifest, such as add/drop CF and CompactFiles, which don't go through any error handling/recovery path at all.

  8. koldat commented on Feb 12, 2020

    @koldat
    ContributorAuthor

    Closing issue as it has a fix. Will reopen if it will happen on latest version. Thanks for help!

  9. added a commit that references this issue on Sep 7, 2022
  10. added a commit that references this issue on Nov 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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