Commit Graph

46863 Commits

Author SHA1 Message Date
Xavier Deguillard
2274399ed8 remotefilelog: refactor hg debughistorypack
Summary:
Move the code that isn't proper to an historypack to a separate function. This
will be used to implement a similar functionality for the
IndexedLogHistoryStore

Reviewed By: quark-zju

Differential Revision: D17104466

fbshipit-source-id: 905a4c4c63d8bbb54611fcb9521ab3039d1b56fd
2019-08-30 18:30:47 -07:00
Xavier Deguillard
66ed398113 bindings: refactor historypack::iterentries
Summary:
This functionality will be needed by the IndexedLogHistoryStore, let's move the
code out of historypack.

Reviewed By: quark-zju

Differential Revision: D17104468

fbshipit-source-id: 33b6b36bb69ed09ca6f72f6f9b6531ffb15c2193
2019-08-30 18:30:47 -07:00
Xavier Deguillard
8fe088a73d asyncrevisionstore: add an async wrapper for the IndexedLogHistoryStore
Summary: See above.

Reviewed By: quark-zju

Differential Revision: D17100018

fbshipit-source-id: 2370c18d608540b9978fcd578618ae4ba14656b7
2019-08-30 18:30:47 -07:00
Xavier Deguillard
8ec0ee1afa asyncrevisionstore: add AsyncMutableHistoryStore
Summary:
This moves code from AsyncMutableHistoryPack. This allows abstracting the type
of history store so the IndexedLogHistoryStore can be easily added.

Reviewed By: quark-zju

Differential Revision: D17100019

fbshipit-source-id: ca226336ae9ff05385f9218e88e853bf6e5356e3
2019-08-30 18:30:46 -07:00
Xinyue Zhang
6331cb6323 Update stablerev.py to work on Windows
Summary:
1.) Windows doesn't support close_fds if stdin/stdout/stderr is redirected. It throws out this Exception: 'close_fds is not supported on Windows platforms if you redirect stdin/stdout/stderr'. This diff resolves this issue by importing mercurial util to use file_fd only on posix
2.) Originally, stable is implemented as a mercurial extension and gets expanded as the following (take update as an example):
```
hg up stable
   -> calls getstablerev("--pick-best") in stable.py
   -> calls a bash script in hg repo, e.g. ovrsource or fbsource
```
However, bash is not supported on Windows.
To resolve this, this diff sets up cwd in `subprocess.Popen` and then modifies stablerev to take in a command in string format instead of a script. This way, we can pass in either the bash script for fbsource(backward compatible) or `python <xxx.py>` for ovrsource.

Reviewed By: quark-zju

Differential Revision: D17140170

fbshipit-source-id: ea8ae76883cc34a0517fa7e9eae3cbb3ba901353
2019-08-30 16:48:18 -07:00
Xavier Deguillard
0f125b4073 remotefilelog: commit the dirty shared mutable packs on transaction abort
Summary:
Since the shared mutable packs contain fetched data from the network, not
commiting them means that we would need to redownload the data again. Let's
persist them on disk instead to avoid having to redownload them.

Reviewed By: quark-zju

Differential Revision: D17115796

fbshipit-source-id: 3e213461c7a864156ee4c6c68e6a042294883f9d
2019-08-30 16:14:52 -07:00
Xavier Deguillard
4b28370d5e remotefilelog: local loosefiles should always be fully repacked
Summary:
The loosefiles repack was made incremental to greatly reduce the repack time
for users. Since the amount of local loosefiles should be way smaller than the
amount of shared ones, let's always run a full repack on the former. This
should allow us to kill all the local loosefiles, which will help in no longer
supporting them.

Reviewed By: quark-zju

Differential Revision: D17135975

fbshipit-source-id: 9480993b31aa57d0d6e6b7caffd282929183f782
2019-08-30 15:09:25 -07:00
Xavier Deguillard
91462ec10e remotefilelog: add a test to show incremental local data repack
Summary:
This illustrate that the local data repack isn't a full one. Note that the test
is a bit flaky due to 1) the underterministic nature of what folder to repack,
and 2) the choice of folder to repack being done twice (one for data, one for
history). Since I won't land this without the next one, this is probably fine.

Reviewed By: quark-zju

Differential Revision: D17135978

fbshipit-source-id: 641d257d0e308b2bb4d91fdc4c214b22e45b4911
2019-08-30 15:09:25 -07:00
Xavier Deguillard
81614017c6 remotefilelog: remove repack Python fallback
Summary:
Now that we're past the point of being not confident about the Rust repack
code, we can remove the fallback code. Instead, let's fail hard if the Rust
repack fails.

Reviewed By: quark-zju

Differential Revision: D17135979

fbshipit-source-id: a521a4f9267361a167bba61968659557bed35e20
2019-08-30 15:09:24 -07:00
Xavier Deguillard
6e0b6a2161 remotefilelog: Rust repack is the default
Summary:
Rust repack has been the default for a while now. Let's stop pretending we're
going to switch back to the Python repack by removing the config entirely.

Reviewed By: quark-zju

Differential Revision: D17135977

fbshipit-source-id: 5aaa0faa48e2b40a7314d5ab455f5eeaa4e4984d
2019-08-30 15:09:24 -07:00
Jun Wu
b178492317 changelog: disable inline revlog
Summary:
The inline revlog format merges `.i` and `.d` into one `.i` file. It was intended to reduce the
number of files for filelogs. For the changelog one extra file does not hurt.

This makes it easier to write native code parsing the changelog revlog index.

Reviewed By: xavierd

Differential Revision: D17125922

fbshipit-source-id: f48ffe0d2df71abec007a80e05b684dcbac71883
2019-08-30 14:58:02 -07:00
Wez Furlong
3a13d58d7a Back out "hg: wrap convert in a big transaction for better pack behavior"
Summary:
I broke some svn tests in that commit, but while fixing forward
realized that we're blocked from making this change because we rely on
rolling back the last commit in the case where the filemap creates an
empty commit.

We can revisit this when we have convert this all to rust!

Reviewed By: sfilipco

Differential Revision: D17140172

fbshipit-source-id: c93911f599afd2d22e84b3327a2a9455204065a0
2019-08-30 14:53:21 -07:00
Wez Furlong
846de7e82f hg: wrap convert in a big transaction for better pack behavior
Summary:
We noticed that the runtime for convert was exponential
due to way that packs were managed.

This wraps the convert in a big transaction so that we reuse an
existing pack rather than writing out one for each commit.

Reviewed By: xavierd

Differential Revision: D17138073

fbshipit-source-id: 46e418a49f917e2ffc411920ace1a3d98ac6b8e4
2019-08-30 14:10:00 -07:00
Xavier Deguillard
8a28530f5f revisionstore: handle indexedlog corruption
Summary:
We've seen a handful of cases where the indexedlogdatastore becomes corrupted
which makes Mercurial unable to run properly. For now, and since we only use
the indexedlog for the hgcache, let's just remove it.

A better solution would be to harden the indexedlog code to better detect the
corruption and attempt to fix them.

Reviewed By: quark-zju

Differential Revision: D17115622

fbshipit-source-id: ee474a5df60c4414f6ea21ace7dff0f7048879c9
2019-08-30 11:26:16 -07:00
Xavier Deguillard
689256b99d remotefilelog: handle missing directory
Summary:
Wez noticed that when /var/cache/hgcache/<repo>/packs/manifest was missing, `hg
repack` would fail, not repacking anything. Let's fix the offending code to
properly ignore the missing directory.

Reviewed By: quark-zju

Differential Revision: D17120206

fbshipit-source-id: 7a7aebac717e5f128565ea2f8d50ffaeda4563f9
2019-08-30 11:23:22 -07:00
Stefan Filip
490a99230c manifest: preserve p1 and p2 order in finalize
Summary:
I had assumed that we store p1 and p2 in the same order that they are used in
Node computation. That is incorrect. In general p1 and p2 are assumed to have
an ordering that matters and it's Node computation that is specific.

Reviewed By: quark-zju

Differential Revision: D17125743

fbshipit-source-id: 3a2673d9c243e2d2103aba0cb4fd8f536386efa7
2019-08-30 10:50:06 -07:00
Stefan Filip
abf02ee9ca manifest: update finalize to work on durable trees
Summary:
In some cases the finalize algorithm is used to persist data that is received
in a bundle. The process is that it constructs a store from the bundle and
goes to construct a tree with the root node received. It then goes through
finalize to generate the entries that need to be written to local storage.

Reviewed By: quark-zju

Differential Revision: D17125149

fbshipit-source-id: de5a1e922a6aebe48e238d8473177a8d3f7a9ef5
2019-08-30 10:50:06 -07:00
Stefan Filip
f8fa8d9367 manifest: add list directory functionality
Summary:
`listdir` returns the contents a directory in the manifest. The format
is pretty simple, containing only the simple names of the files and or
directories. I don't know if this is something that eden can use because
it seems to simple. In other words, we have something but we may want
to iterate on it before we market it broadly.

Reviewed By: quark-zju

Differential Revision: D17098082

fbshipit-source-id: d6aa42c96781cf1f8b2e916fa10bb275593bdc65
2019-08-30 10:50:05 -07:00
Stefan Filip
ffb563f1bb manifest: add subdir_diff compatibility function for gettreepacks
Summary:
The C++ manifest implements walksubdirtrees which is used to compute the packs
that a "client" wants for a prefetch. In terms of interface the function is very
annoying and couples with storage and tree representations without being part
of any of them.

We reproduce that functionality as a means to replace the C++ implementation.
The long term goal is to do lazy fetches using an iteration style that plays
nicer with batching downloads.

This change also includes fastmanifest updates because they are required to
enable the walksubdirtrees functionality in our tests.

Reviewed By: quark-zju

Differential Revision: D17086669

fbshipit-source-id: 6c1f9fbf975814f0a2071f8d1c8e022e5ad58e29
2019-08-30 10:50:05 -07:00
Thomas Orozco
fa4e12df09 wireproto logging: capture getpack
Summary:
ignore-conflict-markers

This updates Mercurial to add a loggetpack option for wire proto logging that
allows capturing getpack responses. This will be useful to verify correctness
for ovrsource on Mononoke (right now, Mononoke isn't serving traffic for hosts
that use getpack).

Reviewed By: StanislavGlebik

Differential Revision: D17091537

fbshipit-source-id: 755a429949d7645010dddab95202c613025f2984
2019-08-30 05:08:18 -07:00
David Tolnay
67f279e778 Update to Rust 1.38.0-beta.3
Reviewed By: bolinfest

Differential Revision: D17128329

fbshipit-source-id: caa2699bf0ae94b33bebd42fb4bbf09d22405056
2019-08-30 02:01:28 -07:00
Thomas Orozco
e4d323a31d hgmain: fix buildinfo compilation & functionality
Summary:
In D16866464, we changed the name of the `args` to `full_args`, which is
causing compilation to fail when buildinfo is enabled:

https://fburl.com/sandcastle/f23unjvj

That said, buildinfo hasn't actually been working (AFAICT), since argv[0] is
the name of the binary, not the first argument, so running `hg buildinfo`
doesn't work, regardless of whether it was compiled in or not. This diff also
fixes that, and reduces the scope of conditional compilation to reduce the
likelihood of this happening again.

Reviewed By: quark-zju

Differential Revision: D17111929

fbshipit-source-id: 720344721f1fe73a3ebe8330c278e4be83d80c00
2019-08-29 10:23:28 -07:00
Xavier Deguillard
309229fdf5 remotefilelog: do no build the entire ancestormap in remotefilectx.parents
Summary:
While working on a stack, I noticed that `hg amend -e` would sometimes download
a lot of history information. For a 4 files change, I saw 738 history entry
fetched individually...

Looking at the profile, this pointed towards remotefilectx.parents requesting
the entire ancestormap. Since that function really only need the nodeinfo,
let's only get that.

Reviewed By: DurhamG

Differential Revision: D17104263

fbshipit-source-id: fae1f673b2d2a641ae4f22d1099317cc5abd8447
2019-08-29 09:51:38 -07:00
Thomas Orozco
243716cdc4 commitcloud: add missing parameter
Summary:
Someone reported an error in this function being called with a missing
argument.

Reviewed By: quark-zju

Differential Revision: D17110694

fbshipit-source-id: 65adbae7e1380652afd1cec8bd3e2bbef27268dd
2019-08-29 09:06:34 -07:00
Jun Wu
ceb7a0c98a doc: update WritingNativeCommands
Summary:
Update the doc to match the latest code.

I put an example at the top. I guess most people aren't interesting in the
implementaion details. With the latest `define_flags!` macro, not knowing
the details does not block people from writing commands.

Tailing spaces are removed.

Reviewed By: sfilipco

Differential Revision: D16733268

fbshipit-source-id: 13c965b7471dd3bc131c20261601f4850c1036c1
2019-08-28 19:26:28 -07:00
Jun Wu
30f293314c clidispatch: support explicitly named arguments in define_flags!
Summary:
This makes it possible to use explicitly named arguments. It can simplify the
code a bit by moving the error handling (incorrect number of arguments) to the
derived code.

Reviewed By: xavierd

Differential Revision: D16905460

fbshipit-source-id: 93dc58d684bb52cd2f9bddc25108ef0c500f81db
2019-08-28 19:26:28 -07:00
Jun Wu
ed3f36bb85 cliparser: return errors if unexpected arguments are provided
Summary:
If there is no `#[args]` field set, the command does not need arguments. In
that case, just error out directly. This can simplify command implementations.

Reviewed By: xavierd

Differential Revision: D16905461

fbshipit-source-id: f4a2d03cf032f34d1b5794010774ff80eb88e1cd
2019-08-28 19:26:28 -07:00
Jun Wu
3c881c88d7 clidispatch: change From to TryFrom for flags parsing
Summary: This make it possible for the flags parsing to return an error.

Reviewed By: xavierd

Differential Revision: D16905462

fbshipit-source-id: 06a70ee7c72132ebb2df453a740b58e6b46dfba2
2019-08-28 19:26:27 -07:00
Jun Wu
06ff75a799 cliparser: add #[command_name] to define_flags!
Summary:
Most commands do not care about the "command name" (aka. arg0). Only commands
sharing a similar implementation (ex. hg up/down/bottom/top) would need it.
Make it optional and make `args` not containing the command name.

Reviewed By: xavierd

Differential Revision: D16905459

fbshipit-source-id: 0a786731ebce2580e116fd50aad75062b03a1fa3
2019-08-28 19:26:27 -07:00
Jun Wu
48e21aebc8 cliparser: add names to define_flags! internal fields
Summary: This makes the code easier to read as we add more fields to the macro state.

Reviewed By: xavierd

Differential Revision: D16905458

fbshipit-source-id: a3bc4dc1accf21cf491921469482f86aec16321b
2019-08-28 19:26:27 -07:00
Jun Wu
a459d31cae testutil/dott: use bindings.commands to run commands
Summary:
This makes it possible to execute Rust commands from the Python tests.

Test changes:
- test-command-template-t: non-utf8 command-line arguments are rejected at the
  function signature level
- test-dispatch-debug-prefix-t: the error is now printed by Rust code, which
  uses spaces instead of tabs.
- test-root-t: the test now passes

Reviewed By: xavierd

Differential Revision: D16866459

fbshipit-source-id: 386931c5497b04c53efc08fbb4de708812517ad9
2019-08-28 19:26:26 -07:00
Jun Wu
c18159134f testutil/dott: set commands.names
Summary:
This gives the Rust code path hints to names of Python command names.

Ideally, the Rust command dispatch logic can just load the Python command table
and figure out it more accurately, and more parts of dispatch.py (ex. extension
loading, debugger, profiler, atexit, etc) are moved to Rust clidispatch or
hgcommands. But that would be a larger change.

Reviewed By: xavierd

Differential Revision: D16866462

fbshipit-source-id: eb993091d5644710686b8f720fd07258b9a5968c
2019-08-28 19:26:26 -07:00
Jun Wu
74d5e02eb8 chg: remove hashstate and validation logic
Summary:
After D7840236 stack, it's possible to have a single chg server that handles
different [extensions] configurations. The 'validate' step and 'hashstate' were
mainly designed to detect changes of [extensions], the source code of the
extensions. That becomes unnecessary with the latest design.

Remove them to simplify the logic.

chg no longer creates symlink `server2 -> server2-hash`. Bump the name
to `server3` to explicitly break compatibility.

Reviewed By: xavierd

Differential Revision: D16866463

fbshipit-source-id: 5e1d00e6f895d9b8ead0bcabefcea11756f57c94
2019-08-28 19:26:26 -07:00
Jun Wu
1a6bc5ff62 hgmain: enable chg
Summary:
Re-enable chg since chg can now run native Rust commands.

In the new state, the dispatch logic tries things in this order:

    - chg (both Python and Rust commands)
      - bindings.commands.run
        - hgcommands::run_command
          - clidispatch (Rust commands)
          - HgPython (Python commands)
            - edenscm.mercurial.entrypoint
              - dispatch.py:run
    - hgcommands (both Rust and Python commands)
      - clidispatch (...)
      - HgPython (...)

Before this stack (D16866461), the old order is:

    - hgcommands (Rust commands only)
      - clidispatch (Rust commands)
    - chg (Python commands only)
      - dispatch.py
    - dispatch.py (Python commands only)

The old order enforces `hgcommands` to not handle Python commands, because of
the undesirable Python startup time overhead comparing to chg. That is bad for
code path unification.

The new approach adds small (5ms) overhead for chg running native commands, but
it helps code unification (hgcommands take care of both Rust and Python), and
perserves the chg perf win.

Code unfication can be pushed further by making clidispatch aware of Python
commands, and move more of dispatch.py to the Rust clidispatch or hgcommands
crate.

Reviewed By: singhsrb

Differential Revision: D16866469

fbshipit-source-id: 79681cb748bd16f200424b6e30ef42aa3111d1bf
2019-08-28 19:26:26 -07:00
Jun Wu
a7721506ed chgserver: use bindings.commands to run commands
Summary:
Use hgcommands via its bindings to run commands. This allows chg to run Rust
commands.

Reviewed By: xavierd

Differential Revision: D16866466

fbshipit-source-id: 0c264a6b5441d2d0b2cdd01beefda5606b00cc61
2019-08-28 19:26:25 -07:00
Jun Wu
60008634e7 hgcommands: pass args and io to Python
Summary:
This makes it possible to capture output of a Python command via the Rust
hgcommands crate.

Reviewed By: xavierd

Differential Revision: D16866467

fbshipit-source-id: e64feece9b31196fabfea110015d5c45cb548046
2019-08-28 19:26:25 -07:00
Jun Wu
36f6462c2d dispatch: make entry point functions accept args and io
Summary:
This allows the Rust `hgcommand` library to use the hg entry point to run
different commands.

Reviewed By: xavierd

Differential Revision: D16866465

fbshipit-source-id: 03078fe76a38c9a01dd6005e03e832162fbeb7e6
2019-08-28 19:26:25 -07:00
Jun Wu
65ecfdc472 bindings: move io module to cpython-ext
Summary: This allows the io module to be used in non-extension code (ex. hgcommands).

Reviewed By: xavierd

Differential Revision: D16866458

fbshipit-source-id: b36b535e3804ba2b8e656508c10ca7ceb3e1fdf1
2019-08-28 19:26:24 -07:00
Jun Wu
636f2ecfdd clidispatch: make IO streams downcast-able
Summary: An upcoming change would like to downcast IO to stdio or PyObjects.

Reviewed By: xavierd

Differential Revision: D16866456

fbshipit-source-id: 73289aab13260ec421b979280f0b9c73383ab5d0
2019-08-28 19:26:24 -07:00
Jun Wu
1fc61320b8 bindings: add commands.run to run Rust commands
Summary: This makes it possible for Python to execute commands implemented in Rust.

Reviewed By: xavierd

Differential Revision: D16866457

fbshipit-source-id: e7352eed0e7b722c28974cb1123975f591ac44bc
2019-08-28 19:26:24 -07:00
Jun Wu
0bf732777a hgcommands: move the actual "run_command" logic from hgmain to hgcommands
Summary:
Expose a simple method in hgcommands to run the actual (Rust or Python) command.
This makes it easier to expose the "runcommand" API via bindings.

I have to disable chg temporarily since `hg root` with chg stops working at present.
chg will be re-enabled in a later diff.

Reviewed By: xavierd

Differential Revision: D16866461

fbshipit-source-id: 46c5df9a577d748fab302a8c7157d8aa62d6f1bd
2019-08-28 19:26:24 -07:00
Jun Wu
16613a894d hgpython: make HgPython take the arguments
Summary:
Previously, HgPython hardcodes the arguments to be std::env::args().
This diff makes that an configurable argument.

Reviewed By: xavierd

Differential Revision: D16866464

fbshipit-source-id: 3a37dd89793e0813732ea9b088ff22c9a4c6b125
2019-08-28 19:26:23 -07:00
Jun Wu
f654b6ebd9 hgcommands: do not call Py_Finalize if Python was not initialized by us
Summary:
`Py_Finalize` is not recursive. It unconditionally destroys the Python interpreter
state. To make `hgcommands` usable in a library (ex. bindings), detect the case
where the interpreter was initialized, and skip `Py_Finalize` in that case.

Reviewed By: markbt

Differential Revision: D16866454

fbshipit-source-id: ea6bb6a83bc0b0fe7b5c2ce21158ae9d9e2a779d
2019-08-28 16:36:21 -07:00
Jun Wu
899614cf65 makefile: remove 'hg version' invocation in make local
Summary:
After D15844921, `hg version` is not running the locally built hg.
This command does not provide much useful information, though - we
have a fixed version number and the commit hash is already known
from `hg sl` or other command output.

Therefore remove `hg version`.

Reviewed By: xavierd

Differential Revision: D17097797

fbshipit-source-id: 184a110a1682ee20c973dca7dcc0e2cfd8660976
2019-08-28 13:54:57 -07:00
Stefan Filip
f8ed4ca01d perftrace: limit the size of the perftrace in blackbox
Summary:
There are cases where Mercurial makes many serial requests to the server.
This diff limits the number of lines that a perftrace can send to blackbox
or print on stderr.

Reviewed By: xavierd

Differential Revision: D17078475

fbshipit-source-id: 8c8313ae0b602160e1018590dd6b87dfffd27662
2019-08-28 11:07:55 -07:00
Aleksei Kulikov
33f371d27c snapshot: bugfix - do not miss the metadata in clean merge state
Summary:
So far we missed the metadata if there were no changes in the WC.
A metadata file was created but was not attached to the commit.

Differential Revision: D17070211

fbshipit-source-id: 646c8bceb575f4302ec60e35472cc55de086d7e0
2019-08-28 03:56:13 -07:00
Jun Wu
49fc1209f1 rage: filter out less interesting entries from blackbox
Summary:
Filter out legacy logs without messages and the `remotefilelog` entries so the
blackbox section can look cleaner.

Reviewed By: sfilipco

Differential Revision: D17054398

fbshipit-source-id: 6485f1832fc12d6f68ed3fb1efe3dbc853af4b1f
2019-08-27 12:11:01 -07:00
Xavier Deguillard
800e44a553 revisionstore: add an indexedlog based historystore
Summary:
The indexedlog based datastore is being rolled out more broadly, let's add a
basic historystore indexedlog to replace the historypacks. One of its first use
will be in hg_memcache_client write path to remove some pathological cases
where hg_memcache_client can write thousands of packfiles. This in turn will
remove the need to run repack to keep the amount of packfiles in control.

The IndexedLog key is the concatenation of sha1(path) and the node. Hashing the
path should be fairly cheap and makes it easy to integrate with the IndexedLog.

One of the drawback versus the histpack will be storage space usage, as the
path is always stored per entry, while it was shared with multiple entries in
the history pack. I though about having a separate index to easily translate
the hashed path to the path, but due to the potential log rotation, we could
end-up in a case where the path isn't present at all in the store.

Reviewed By: quark-zju

Differential Revision: D16616082

fbshipit-source-id: 1e47260b479f8923cc137a39dcba54b2d074f43a
2019-08-27 11:58:53 -07:00
Shu-Ting Tseng
439e4c6825 port D16833526 to gitrevset
Summary:
See https://fb.workplace.com/groups/corehg/permalink/448152285780007/ for context.

D16833526 was to add extras lookup for translating hg hash to git hash. However we
also have gitrevset extension which still does mapfile lookup. THis diff should port
the same improvement for it.

Reviewed By: DurhamG

Differential Revision: D17070479

fbshipit-source-id: e469707b0b21541aa2c3b90d1480b04afc4f1485
2019-08-27 11:56:01 -07:00
Jun Wu
66cef07cf9 indexedlog: add a fsync option to Log and Index
Summary:
Add a way to explicitly `fsync` data to reduce changes of data corruption in
case of hard reboots.

If `fsync` is set on a `Log`, it sets `fsync` recursively on its indexes and
checksum tables. If frequent `fsync` is an issue, it might be possible to only
`fsync` the source of truth (log and meta) and have other logic to rebuild
indexes on demand.

`fsync` on btrfs seems to be relatively cheap (comparing to ext4), so maybe
this is fine for btrfs users.

Reviewed By: markbt

Differential Revision: D16926659

fbshipit-source-id: a9de2fa352f607fe6f0b9d36047323862770f2e6
2019-08-26 19:57:20 -07:00