Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Temporary work around nullptr seqno_to_time_mapping in FlushJob #13269

Conversation

pdillinger
Copy link
Contributor

Summary: To resolve a crash test failure in
FlushJob::GetPrecludeLastLevelMinSeqno()

To fix this properly, I will work on ensuring that (a) FlushJob is created with a consistent view on mutable options and seqno_to_time_mapping (from a single SuperVersion) and (b) SuperVersions always have a non-null seqno_to_time_mapping when a relevant option is set.

Test Plan: watch crash test

Summary: To resolve a crash test failure in
`FlushJob::GetPrecludeLastLevelMinSeqno()`

To fix this properly, I will work on ensuring that (a) FlushJob is
created with a consistent view on mutable options and
seqno_to_time_mapping (from a single SuperVersion) and (b) SuperVersions
always have a non-null seqno_to_time_mapping when a relevant option is
set.

Test Plan: watch crash test
@facebook-github-bot
Copy link
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
Contributor

@pdillinger merged this pull request in 09d7f6a.

pdillinger added a commit to pdillinger/rocksdb that referenced this pull request Jan 18, 2025
Summary: This is an unexpectedly complex follow-up to facebook#13269.

This change solves (and detects regressed) inconsistencies between
whether a CF's SuperVersion is configured with a preserve/preclude
option and whether it gets a usable SeqnoToTimeMapping. Operating
with preserve/preclude and no usable mapping is degraded functionality
we need to avoid. And no mapping is useful for actually disabling the
feature (except with respect to existing SST files, but that's less of a
concern for now).

The challenge is that how we maintain the DB's SeqnoToTimeMapping can
depend on all the column families, and we don't want to iterate over all
column families *for each column family* (e.g. on initially creating
each). The existing code was a bit relaxed:
* On initially creating or re-configuring a CF, we might install an
  empty mapping, but soon thereafter (after releasing and re-acquiring
  the DB mutex) re-install another SuperVersion with a useful mapping.

The solution here is to refactor the logic so that there's a distinct
but related workflow for (a) ensuring a quality set of mappings when we
might only be considering a single CF (`EnsureSeqnoToTimeMapping()`),
and (b) massaging that set of mappings to account for all CFs
(`RegisterRecordSeqnoTimeWorker`) which doesn't need to re-install new
SuperVersions because each CF already has good mappings and will get
updated SuperVersions when the periodic task adds new mappings. This
should eliminate the extra SuperVersion installs associated with
preserve/preclude on CF creation or re-configure, making it the same as
any other CF.

Some more details:
* Some refactorings such as removing new_seqno_to_time_mapping from
  SuperVersionContext. (Now use parameter instead of being stateful.)
* Propagate `read_only` aspect of DB to more places so that we can
  pro-actively disable preserve/preclude on read-only DBs, so that we
  don't run afoul of the assertion expecting SeqnoToTime entries.
* Introduce a utility struct `MinAndMaxPreserveSeconds` for aggregating
  preserve/preclude settings in a useful way, sometimes on one CF and
  sometimes across multiple CFs. Much cleaner! (IMHO)
* Introduce a function `InstallSuperVersionForConfigChange` that is a
  superset of `InstallSuperVersionAndScheduleWork` for when a CF is new
  or might have had a change to its mutable options.
* Eliminate redundant re-install SuperVersions of created "missing" CFs
  in DBImpl::Open.

Intended follow-up:
* Ensure each flush has an "upper bound" SeqnoToTime entry, which would
  resolve a FIXME in tiered_compaction_test, but causes enough test
  churn to deserve its own PR + investigation.

Test Plan: This change is primarily validated by a new assertion in
SuperVersion::Init to ensure consistency between (a) presence of any
SeqnoToTime mappings in the SuperVersion and (b) preserve/preclude
option being currently set.

One unit test update was needed because we now ensure at least one
SeqnoToTime entry is created on any DB::Open with preserve/preclude, so
that there is a lower bound time on all the future data writes. This
required a small hack in associating the time with Seqno 1 instead of 0,
which is reserved for "unspecified old."
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