Skip to content

Update tiered storage tests (ahead of next change) - #11917

Closed
pdillinger wants to merge 1 commit into
meta:mainfrom
pdillinger:prep_tiered_tests
Closed

pdillinger wants to merge 1 commit into
meta:mainfrom
pdillinger:prep_tiered_tests

Conversation

@pdillinger

Copy link
Copy Markdown
Contributor

Summary:
After #11905, I am preparing a DBImpl change to ensure all sufficiently recent sequence numbers since Open are covered by SeqnoToTimeMapping. Intended follow-up

However, there are a number of test changes I want to make prior to that to make it clear that I am not regressing the tests and production behavior at the same time.

  • Start mock time in the tests well beyond epoch (time 0) so that we aren't normally reaching into pre-history for current time minus the preserve/preclude duration.
  • Majorly clean up BasicSeqnoToTimeMapping to avoid confusing hard-coded bounds on GetProximalTimeBeforeSeqno() results.
    • There is an unresolved/unexplained issue marked with FIXME that should be investigated when GetProximalTimeBeforeSeqno() is put into production.
  • MultiCFs test was strangely generating 5 L0 files, four of which would be compacted into an L1, and then letting TTL compaction compact 1@L0+1@L1. Changing the starting time of the tests seemed to mess up the TTL compaction. But I suspect the TTL compaction was unintentional, so I've cut it down to just 4 L0 files, which compacts predictably.
  • Unrelated: allow ROCKSDB_NO_STACK=1 to skip printing a stack trace on assertion failures.

Test Plan: no changes to production code

Summary:
After meta#11905, I am preparing a DBImpl change to ensure all sufficiently
recent sequence numbers since Open are covered by SeqnoToTimeMapping.
**Intended follow-up**

However, there are a number of test changes I want to make prior to that
to make it clear I'm not entangling those test changes with possible
regressions in production behavior.

* Start mock time in the tests well beyond epoch (time 0) so that we
aren't normally reaching into pre-history for current time minus
preserve/preclude duration.
* Majorly clean up BasicSeqnoToTimeMapping to avoid confusing hard-coded
bounds on GetProximalTimeBeforeSeqno() results.
  * There is an unresolved/unexplained issue marked with FIXME that
  should be investigated when GetProximalTimeBeforeSeqno() is put
  into production.
* MultiCFs test was strangely generating 5 L0 files, four of which would
be compacted into an L1, and then letting TTL compaction compact
1@L0+1@L1. Changing the starting time of the tests seemed to mess up the
TTL compaction. But I suspect the TTL compaction was unintentional, so
I've cut it down to just 4 L0 files, which compacts predictably.
* Unrelated: allow ROCKSDB_NO_STACK=1 to skip printing a stack trace on
assertion failures.

Test Plan: no changes to production code
Comment thread db/seqno_time_test.cc
// The result is within the range
ASSERT_GE(tp_mapping.GetProximalTimeBeforeSeqno(i), (i - 10) * 10);
ASSERT_LE(tp_mapping.GetProximalTimeBeforeSeqno(i), (i + 10) * 10);
ASSERT_GE(tp_mapping.GetProximalTimeBeforeSeqno(i),

@jowlyzhang jowlyzhang Oct 2, 2023 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick question: how is this window size 100 determined?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I basically just chose a narrower window than was there before. Let me see if I can revise that down or make more sense where inaccuracies are.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right. "the sample rate is 10000/100." We only collect next sample after mock 100s has passed, so the reported time can be up to 100s older than the true value.

@jowlyzhang jowlyzhang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the improvement!

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@pdillinger has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@pdillinger merged this pull request in 7bebd30.

pdillinger added a commit to pdillinger/rocksdb that referenced this pull request Oct 4, 2023
Summary: This change has two primary goals (follow-up to meta#11917, meta#11920):
* Ensure the DB seqno_to_time_mapping has entries that allow us to put a
good time lower bound any writes that happen after setting up
preserve/preclude options (either in a new DB, new CF, SetOptions,
etc.). This allows us to remove a bunch of work-arounds in tests.
* For new DBs using preserve/preclude options, automatically reserve
some sequence numbers and pre-map them to cover the time span back to
the preserve/preclude cut-off time. In the future, this will allow us to
import data from another DB by key, value, and write time by assigning
an appropriate seqno in this DB for that write time.

Note that the pre-population (back in time mappings) does not happen if
the original options at DB Open time do not have preserve/preclude, so
creating initial column families at that time with
create_missing_column_families is recommended to take advantage of this
(future) feature. (Adding these mappings back in time after DB Open
would risk non-monotonic seqno_to_time_mapping, which is dubious if not
dangerous.)

Recommended follow-up:
* Solve existing race conditions (not memory safety) where parallel
operations like CreateColumnFamily or SetDBOptions could leave the wrong
setting in effect.
* Make SeqnoToTimeMapping more gracefully handle a possible case in
which too many mappings are added for the time range of concern. It
seems like there could be cases where data is massively excluded from
the cold tier because of entries falling off the front of the mapping
list (causing GetProximalSeqnoBeforeTime() to return 0). (More
investigation needed.)

No release note for the minor bug fix because this is still an
experimental feature with limited usage.

Test Plan: tests added / updated
pdillinger added a commit to pdillinger/rocksdb that referenced this pull request Oct 4, 2023
Summary: This change has two primary goals (follow-up to meta#11917, meta#11920):
* Ensure the DB seqno_to_time_mapping has entries that allow us to put a
good time lower bound any writes that happen after setting up
preserve/preclude options (either in a new DB, new CF, SetOptions,
etc.). This allows us to remove a bunch of work-arounds in tests.
* For new DBs using preserve/preclude options, automatically reserve
some sequence numbers and pre-map them to cover the time span back to
the preserve/preclude cut-off time. In the future, this will allow us to
import data from another DB by key, value, and write time by assigning
an appropriate seqno in this DB for that write time.

Note that the pre-population (back in time mappings) does not happen if
the original options at DB Open time do not have preserve/preclude, so
creating initial column families at that time with
create_missing_column_families is recommended to take advantage of this
(future) feature. (Adding these mappings back in time after DB Open
would risk non-monotonic seqno_to_time_mapping, which is dubious if not
dangerous.)

Recommended follow-up:
* Solve existing race conditions (not memory safety) where parallel
operations like CreateColumnFamily or SetDBOptions could leave the wrong
setting in effect.
* Make SeqnoToTimeMapping more gracefully handle a possible case in
which too many mappings are added for the time range of concern. It
seems like there could be cases where data is massively excluded from
the cold tier because of entries falling off the front of the mapping
list (causing GetProximalSeqnoBeforeTime() to return 0). (More
investigation needed.)

No release note for the minor bug fix because this is still an
experimental feature with limited usage.

Test Plan: tests added / updated
facebook-github-bot pushed a commit that referenced this pull request Oct 6, 2023
Summary:
This change has two primary goals (follow-up to #11917, #11920):
* Ensure the DB seqno_to_time_mapping has entries that allow us to put a good time lower bound on any writes that happen after setting up preserve/preclude options (either in a new DB, new CF, SetOptions, etc.) and haven't yet aged out of that time window. This allows us to remove a bunch of work-arounds in tests.
* For new DBs using preserve/preclude options, automatically reserve some sequence numbers and pre-map them to cover the time span back to the preserve/preclude cut-off time. In the future, this will allow us to import data from another DB by key, value, and write time by assigning an appropriate seqno in this DB for that write time.

Note that the pre-population (historical mappings) does not happen if the original options at DB Open time do not have preserve/preclude, so it is recommended to create initial column families at that time with create_missing_column_families, to take advantage of this (future) feature. (Adding these historical mappings after DB Open would risk non-monotonic seqno_to_time_mapping, which is dubious if not dangerous.)

Recommended follow-up:
* Solve existing race conditions (not memory safety) where parallel operations like CreateColumnFamily or SetDBOptions could leave the wrong setting in effect.
* Make SeqnoToTimeMapping more gracefully handle a possible case in which too many mappings are added for the time range of concern. It seems like there could be cases where data is massively excluded from the cold tier because of entries falling off the front of the mapping list (causing GetProximalSeqnoBeforeTime() to return 0). (More investigation needed.)

No release note for the minor bug fix because this is still an experimental feature with limited usage.

Pull Request resolved: #11922

Test Plan: tests added / updated

Reviewed By: jowlyzhang

Differential Revision: D49956563

Pulled By: pdillinger

fbshipit-source-id: 92beb918c3a298fae9ca8e509717b1067caa1519
facebook-github-bot pushed a commit that referenced this pull request Nov 13, 2023
…Overlap` (#12064)

Summary:
Fixes #11909. The test passes after the change in #11917 to start mock clock from a non-zero time.

The reason for test failing is a bit complicated:
- The Put here https://github.com/pdillinger/rocksdb/blob/e4ad4a0ef1b852dc203311fb885c673c891f08e0/db/compaction/tiered_compaction_test.cc#L2045 happens before mock clock advances beyond 0.
- This causes oldest_key_time_ to be 0 for memtable.
- oldest_ancester_time of the first L0 file becomes 0
- L0 -> L5/6 compaction output files sets `oldest_ancestoer_time` to the current time due to these lines: https://github.com/facebook/rocksdb/blob/509947ce2c970d296fd0d868455d560c7f778a57/db/compaction/compaction_job.cc#L1898C34-L1904.
- This causes some small sequence number to be mapped to current time: https://github.com/facebook/rocksdb/blob/509947ce2c970d296fd0d868455d560c7f778a57/db/compaction/compaction_job.cc#L301
- Keys in L6 is being moved up to L5 due to the unexpected seqno_to_time mapping
- When compacting keys from last level to the penultimate level, we only check keys to be within user key range of penultimate level input files. If we compact the following file 3 with file 1 and output keys to L5, we can get the reported inconsistency bug.
```
L5: file 1 [K5@20, K10@kMaxSeqno], file 2 [K10@30, K14@34)
L6: file 3 [K6@5, K10@20]
```

#12063 will add fixes to check internal key range when compacting keys from last level up to the penultimate level.

Pull Request resolved: #12064

Test Plan: the unit test passes

Reviewed By: ajkr

Differential Revision: D51281149

Pulled By: cbi42

fbshipit-source-id: 00b7f026c453454d9f3af5b2de441383a96f0c62
Tim-Reed pushed a commit to Tim-Reed/rocksdb that referenced this pull request Oct 1, 2026
Summary:
After meta#11905, I am preparing a DBImpl change to ensure all sufficiently recent sequence numbers since Open are covered by SeqnoToTimeMapping. **Intended follow-up**

However, there are a number of test changes I want to make prior to that to make it clear that I am not regressing the tests and production behavior at the same time.

* Start mock time in the tests well beyond epoch (time 0) so that we aren't normally reaching into pre-history for current time minus the preserve/preclude duration.
* Majorly clean up BasicSeqnoToTimeMapping to avoid confusing hard-coded bounds on GetProximalTimeBeforeSeqno() results.
  * There is an unresolved/unexplained issue marked with FIXME that should be investigated when GetProximalTimeBeforeSeqno() is put into production.
* MultiCFs test was strangely generating 5 L0 files, four of which would be compacted into an L1, and then letting TTL compaction compact 1@L0+1@L1. Changing the starting time of the tests seemed to mess up the TTL compaction. But I suspect the TTL compaction was unintentional, so I've cut it down to just 4 L0 files, which compacts predictably.
* Unrelated: allow ROCKSDB_NO_STACK=1 to skip printing a stack trace on assertion failures.

Pull Request resolved: meta#11917

Test Plan: no changes to production code

Reviewed By: jowlyzhang

Differential Revision: D49841436

Pulled By: pdillinger

fbshipit-source-id: 753348ace9c548e82bcb77fcc8b2ffb7a6beeb0a
Tim-Reed pushed a commit to Tim-Reed/rocksdb that referenced this pull request Oct 1, 2026
Summary:
This change has two primary goals (follow-up to meta#11917, meta#11920):
* Ensure the DB seqno_to_time_mapping has entries that allow us to put a good time lower bound on any writes that happen after setting up preserve/preclude options (either in a new DB, new CF, SetOptions, etc.) and haven't yet aged out of that time window. This allows us to remove a bunch of work-arounds in tests.
* For new DBs using preserve/preclude options, automatically reserve some sequence numbers and pre-map them to cover the time span back to the preserve/preclude cut-off time. In the future, this will allow us to import data from another DB by key, value, and write time by assigning an appropriate seqno in this DB for that write time.

Note that the pre-population (historical mappings) does not happen if the original options at DB Open time do not have preserve/preclude, so it is recommended to create initial column families at that time with create_missing_column_families, to take advantage of this (future) feature. (Adding these historical mappings after DB Open would risk non-monotonic seqno_to_time_mapping, which is dubious if not dangerous.)

Recommended follow-up:
* Solve existing race conditions (not memory safety) where parallel operations like CreateColumnFamily or SetDBOptions could leave the wrong setting in effect.
* Make SeqnoToTimeMapping more gracefully handle a possible case in which too many mappings are added for the time range of concern. It seems like there could be cases where data is massively excluded from the cold tier because of entries falling off the front of the mapping list (causing GetProximalSeqnoBeforeTime() to return 0). (More investigation needed.)

No release note for the minor bug fix because this is still an experimental feature with limited usage.

Pull Request resolved: meta#11922

Test Plan: tests added / updated

Reviewed By: jowlyzhang

Differential Revision: D49956563

Pulled By: pdillinger

fbshipit-source-id: 92beb918c3a298fae9ca8e509717b1067caa1519
Tim-Reed pushed a commit to Tim-Reed/rocksdb that referenced this pull request Oct 1, 2026
…Overlap` (meta#12064)

Summary:
Fixes meta#11909. The test passes after the change in meta#11917 to start mock clock from a non-zero time.

The reason for test failing is a bit complicated:
- The Put here https://github.com/pdillinger/rocksdb/blob/e4ad4a0ef1b852dc203311fb885c673c891f08e0/db/compaction/tiered_compaction_test.cc#L2045 happens before mock clock advances beyond 0.
- This causes oldest_key_time_ to be 0 for memtable.
- oldest_ancester_time of the first L0 file becomes 0
- L0 -> L5/6 compaction output files sets `oldest_ancestoer_time` to the current time due to these lines: https://github.com/facebook/rocksdb/blob/e9c5eb70d180fe0a1b80f91998c084e40714c23b/db/compaction/compaction_job.cc#L1898C34-L1904.
- This causes some small sequence number to be mapped to current time: https://github.com/facebook/rocksdb/blob/e9c5eb70d180fe0a1b80f91998c084e40714c23b/db/compaction/compaction_job.cc#L301
- Keys in L6 is being moved up to L5 due to the unexpected seqno_to_time mapping
- When compacting keys from last level to the penultimate level, we only check keys to be within user key range of penultimate level input files. If we compact the following file 3 with file 1 and output keys to L5, we can get the reported inconsistency bug.
```
L5: file 1 [K5@20, K10@kMaxSeqno], file 2 [K10@30, K14@34)
L6: file 3 [K6@5, K10@20]
```

meta#12063 will add fixes to check internal key range when compacting keys from last level up to the penultimate level.

Pull Request resolved: meta#12064

Test Plan: the unit test passes

Reviewed By: ajkr

Differential Revision: D51281149

Pulled By: cbi42

fbshipit-source-id: 00b7f026c453454d9f3af5b2de441383a96f0c62
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants