Skip to content

Clarification on max_total_wal_size #5789

Closed

Description

@adamretter

I understand that max_total_wal_size is defined per-database. The C++ doc describes that when set to 0 it should be calculated dynamically as:

If set to 0
// (default), we will dynamically choose the WAL size limit to be
// [sum of all write_buffer_size * max_write_buffer_number] * 4

Using RocksDB git HEAD at 2019-06-23, if I set max_total_wal_size = 0, and then for each of my 15 CFs (Column Families) set:

write_buffer_size = 128 MB
max_write_buffer_number = 6

We don’t do any manual flushes, and instead we are relying on the max_total_wal_size formula to flush the Column families when the WAL exceeds its setting.

After loading about 10GB of data across about the column families into a clean database, and then leaving the system to idle for some hours, I am still seeing *.log files on disk totalling about ~20GB.

Unfortunately, I believe either one of two things is happening:

  1. I am misunderstanding how the above dynamic calculation works, or
  2. there is a bug whereby max_total_wal_size is not dynamically calculated correctly.

I was expecting the flush and WAL cleanup to happen at: (128MB * 6) * 4 = 3GB.

I am wondering how to interpret the text "sum of all write_buffer_size". Should it actually mean the total WAL size across all column families instead, i.e.: (15 CFs * (128MB * 6)) * 4 = 45GB ?

Activity

  1. changed the title [-]Clarification on `max_total_wal_size = 0`[/-] [+]Clarification on max_total_wal_size[/+] on Sep 10, 2019
  2. anand1976 commented on Sep 10, 2019

    @anand1976
    Contributor

    Yes, it is the total WAL size across all column families. The WAL is shared by all column families, so the max WAL size is the aggregate.

  3. adamretter commented on Sep 10, 2019

    @adamretter
    CollaboratorAuthor

    @ananclub Okay, so the settings I posted:

    write_buffer_size = 128 MB
    max_write_buffer_number = 6
    

    were set for me by RocksDB when I called OptimizeLevelStyleCompaction on each Column Family.

    Doing so, it seems that I have ended up with a very large dynamic WAL max_total_wal_size.
    Is there any way to have a smaller dynamic WAL max_total_wal_size?

  4. siying commented on Sep 10, 2019

    @siying
    Contributor

    @anand1976 I looked at the implementation of max_total_wal_size = 0 but I feel it is odd. It appears that DBImpl::max_total_in_memory_state_ should be the actual value to use, but in db_impl_compaction_flush.cc, the value is updated in a way that makes no sense to me. Maybe we should track back the history and see how this problematic line was added.

  5. anand1976 commented on Sep 10, 2019

    @anand1976
    Contributor

    @siying I don't see anything wrong in how max_total_in_memory_state_ is being updated in db_impl_compaction_flush.cc. It seems to be adjusting the value in case there was any change to the write_buffer_size or max_write_buffer_number parameters. Am I missing something?

  6. siying commented on Sep 10, 2019

    @siying
    Contributor

    @anand1976 oh I got it. Hmm, Maybe there is not bug there.

  7. siying commented on Sep 10, 2019

    @siying
    Contributor

    I don't know what's the problem then.

  8. anand1976 commented on Sep 10, 2019

    @anand1976
    Contributor

    @adamretter You can always explicitly set max_total_wal_size. Interestingly, we have the db_write_buffer_size and write_buffer_manager options to limit the overall memory consumption by memtables, but they don't seem to influence the default max_total_wal_size calculation.

    Cc @maysamyabandeh @riversand963 who may have more expertise in how the WAL works.

  9. siying commented on Sep 10, 2019

    @siying
    Contributor

    @anand1976 db_write_buffer_size and write_buffer_manager are for control memtable memory. max_total_wal_size is to control WAL size limit. These can mostly mean the same thing but not absolute. They also pick memtable to flush in different ways as far as I remember.

  10. anand1976 commented on Sep 11, 2019

    @anand1976
    Contributor

    @adamretter Are you writing evenly to all the CFs? If so, then I think there may be a bug because every CF memtable should get flushed regularly, and none of them should hold a reference to very old log files. You can dump the manifest to see the log number for each CF (and min_log_number_to_keep if you've enabled 2pc).

  11. adamretter commented on Sep 11, 2019

    @adamretter
    CollaboratorAuthor

    @anand1976 I am not quite sure what you mean by "evenly"?

    If it is about the amount of data in each CF... then some of our CFs have much more data than others.

    Could you point me to some documentation about how to dump the manifest?

  12. anand1976 commented on Sep 11, 2019

    @anand1976
    Contributor

    If it is about the amount of data in each CF... then some of our CFs have much more data than others.

    Its possible one or more CFs have not been flushed for a very long time.

    To dump manifest - ldb manifest_dump --path=<path_to_manifest_file>

  13. siying commented on Sep 11, 2019

    @siying
    Contributor

    @adamretter I guess the only task left is to improve the comment to the option?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions