Commit Graph

47218 Commits

Author SHA1 Message Date
Thomas Orozco
1147c48791 clienttelemetry: log peer name to blackbox
Summary:
This updates clienttelemetry to log the peer name to the hg blackbox (on every
connection). This might make it easier to understand which host a given hg is
connecting to even if we can't get to its logs (e.g. in our external sync
processes, we are capturing output to match it for errors, so it's not trivial
to get the remote hostname even with clienttelemetry.announceremotehostname.

It's possible to retrieve the peer name with e.g.: ` hg blackbox --pattern '{"clienttelemetry": "_"}'`

Reviewed By: ikostia

Differential Revision: D17808834

fbshipit-source-id: 5c8afca6bd8b3bbbf14ec8d8efb3f9b1f6b25986
2019-10-09 06:19:44 -07:00
Jun Wu
e8b33179a6 indexedlog: chmod dirs to 0o2755
Summary:
This hopefully removes some potential headaches related to POSIX filesystem
ACL.

See also: https://github.com/rust-lang/rust/issues/22415

Reviewed By: sfilipco

Differential Revision: D17822331

fbshipit-source-id: 60fff6edecea63b6102f7a765eae058a14686efe
2019-10-08 17:45:16 -07:00
Jun Wu
3517d850b7 indexedlog: chmod tempfile to 0o644
Summary:
This is similar to D15580364. It should fix an issue where RotateLog does not
create indexes in 0o666 mode.

Reviewed By: sfilipco

Differential Revision: D17821986

fbshipit-source-id: 76f658d367ec72f640299bcf399d10df1c8ecd19
2019-10-08 17:45:15 -07:00
Jun Wu
28c65b97c4 repo: turn off narrow-heads if visibleheads is not used
Summary:
It's possible that visible heads is enabled but the repo is not migrated to use
it. In that case, narrow-heads cannot really be used. So let's disable
narrow-heads if visibleheads is not used.

Reviewed By: sfilipco

Differential Revision: D17804501

fbshipit-source-id: 6aa7046497c7fd9bbd33561de66c34e7085bcfc5
2019-10-08 17:41:53 -07:00
Jun Wu
4cd847426e tests: enable narrow-heads for "test-amend-restack.t"
Summary: It only chagnes some `--hidden` related tests. The new behavior looks okay.

Reviewed By: sfilipco

Differential Revision: D17804371

fbshipit-source-id: 2cf6d3f1a622e7006e7e340f2a9b5ec30c224e49
2019-10-08 17:41:52 -07:00
Jun Wu
e45b702c2d tests: enable mutation and visibility for "test-amend-restack.t"
Summary: Commit hash changes are caused by mutation metadata written to the commits.

Reviewed By: sfilipco

Differential Revision: D17804368

fbshipit-source-id: 494be9d1fd385d31fd4e38c4b27af1ce4026c1c3
2019-10-08 17:41:52 -07:00
Jun Wu
0d91e3a967 tests: fix "test-amend-restack.t"
Summary:
By defining `mkcommit`, this test now passes.

The runtime dropped from 50+ seconds to 6 seconds.

Reviewed By: sfilipco

Differential Revision: D17801572

fbshipit-source-id: 039e6d210259605870451871d8b70eb01413d9b3
2019-10-08 17:41:52 -07:00
Jun Wu
5953d0c676 tests: auto translate "test-amend-restack.t"
Summary:
This is done by running:

  ./translate "test-amend-restack.t"

Reviewed By: sfilipco

Differential Revision: D17801573

fbshipit-source-id: d0a29ba8d6380ddfad806fd45478d87425f3efd5
2019-10-08 17:41:52 -07:00
Jun Wu
ab3c353391 visibility: use revlogindex to answer heads(ancestors(...))
Summary: This should speed up `visibility._updateheads`.

Reviewed By: DurhamG

Differential Revision: D17804370

fbshipit-source-id: a0ac167a7cc54d7e02ab62e651a8ad13fbd1c383
2019-10-08 17:41:51 -07:00
Jun Wu
50f91dd880 phases: repo.invalidatevolatilesets invalidates phases cache
Summary:
`repo.invalidatevolatilesets` is intended to invalidate revsets like
`obsolete()`, useful when new commits are created.

`obsolete()` actually depends on phase revsets like `draft()`. So let's
invalidate phase cache too for correctness.

This should fix an issue where `hg amend --restack` wouldn't restack
commits correctly. The test will be added in an upcoming change.

This will make operations like rebase slower by about 0.1s. We'll
regain perf once moved to the more advanced dag structure.

Reviewed By: sfilipco

Differential Revision: D17804369

fbshipit-source-id: bc3c8225d0f3ff0cd774e3555d4e4d3a55dc4168
2019-10-08 17:41:51 -07:00
Durham Goode
bacb4eef40 Update hg integration to work with new filesystem layer
Summary:
Mercurial has refactored its dirstate into a dirstate and a filesystem
layer. Currently, the responsibility of the filesystem layer is to just report
what files have changed from the pristine tree.

This diff refactors the eden dirstate integration to match this new layering. We
can now delete most of the eden dirstate status implementation and simply
implement the filesystem.pendingchanges api instead. Eden status goes from 135
lines down to 26.

Reviewed By: chadaustin

Differential Revision: D17174279

fbshipit-source-id: 2bee715ecba0ad46bf403374417c8b025b7205ae
2019-10-08 16:45:09 -07:00
Durham Goode
cc3ea5bf66 fsmonitor: convert fsmonitor to use new filesystem abstraction
Summary:
The new filesystem abstraction hides the complexity of fsmonitor behind
a single "pendingchanges" call, which only takes a matcher and a boolean for
listing ignore files. This diff refactors the fsmonitor logic to work with this
new API instead of the old walk api.

Reviewed By: quark-zju

Differential Revision: D17142419

fbshipit-source-id: d068ec684668df4fe3ff07a95fc3134ddc5cb4dc
2019-10-08 16:45:09 -07:00
Durham Goode
b7680284ca filesystem: implement fs.pendingchanges()
Summary:
dirstate.status can be thought of as three stages: 1) checking what
files have changed on disk, 2) adding nonnormal files (added, removed, copied,
merged), and 3) adding clean files. The current implementation ties these
together in one big pile.

As part of refactoring the working copy interface into clear working copy and
filesystem interfaces, this diff extracts the "check what files have changed on
disk" part into the filesystem class.

Note, this implements a walk function very similar to the one that exists in
dirstate. The difference is that dirstate.walk cares about everything that is in
the dirstate already, while the fs walk only cares about what files are
different from the pristine tree, so it's easier to reason about.

Note: This diff does not update the fsmonitor or eden dirstate implementations.
That means those tests will break if I land this. I'm going to send two more diffs
to update their implementations, then I'll be sure to land them all at once.

Future cleanup:
- lookup resolution should be done inside the filesystem layer, since it's an
  artifact of filesystem limitations.
- I'd like to get rid of ignore file special casing and have that just be part
  of the matcher that is passed in. This might not be feasible though.
- I'd like to get rid of explicit file special casing and have the caller handle
  that if needed.
- I'd like to remove the ability to list clean files in status. Most callers
  don't need that capability, and a caller could compute that themselves if
  needed.

Reviewed By: quark-zju

Differential Revision: D17099990

fbshipit-source-id: d7530e26f057d8fd38aaa36512fa398a543b23c2
2019-10-08 16:45:09 -07:00
Durham Goode
a0ec26e501 purge: move purge into filesystem layer
Summary:
Eden wants to be able to perform the purge itself, so Mercurial doesn't
have to walk over the whole tree and so it can do it in bulk. Let's start by
refactoring purge to be implemented within the filesystem layer, and moving the
current implementation down.

Reviewed By: quark-zju

Differential Revision: D17142418

fbshipit-source-id: 13b2dc892756ab79c12b62071930264dc99ee511
2019-10-08 16:45:08 -07:00
Durham Goode
cd744f29f6 commitcloud: add commitcloud status to debugcrdump
Summary:
We eventually want to depend on all commits being uploaded to commit
cloud, instead of passing bundles to other services. To start this process,
let's make hg debugcrdump (which is used by jf submit) force the upload of the
given commits.

This required a minor refactor the backup.backup to make it more usable by logic
other than the backup command. I applied the same pattern to sync as well,
though it wasn't strictly necessary.

In a future diff we'll add logging to track how many jf submits send commits
that are not uploaded to commit cloud.

Reviewed By: mitrandir77

Differential Revision: D17721168

fbshipit-source-id: d191cfe3356a9bb2956a33921e13d317f7ed4ee5
2019-10-08 16:10:55 -07:00
Jun Wu
c2f9d6c20a hiddenoverride: disable itself if visibility is enabled
Summary:
`hiddenoverride` was a hack to override visibility.  So if visibility is
tracked explicitly, there is no need to enable hiddenoverride.

This breaks the visibility upgrade feature, but we have shipped visibility for
a long time.

Reviewed By: sfilipco

Differential Revision: D17812491

fbshipit-source-id: 58d70165be9265de1beb9600ae5ec72f6db22e6a
2019-10-08 16:05:11 -07:00
Jun Wu
6e95d6be31 commands: implement 'hg continue'
Summary: It's easier to type than `hg foo --continue`.

Reviewed By: sfilipco

Differential Revision: D17768760

fbshipit-source-id: a34d8e4e15421a9205a6b8ececd9ee2294ed8734
2019-10-08 14:20:55 -07:00
Jun Wu
5307cbf7ab cmdutil: remove i18n for afterresolvedstates
Summary:
Commands like `hg rebase --continue` shouldn't be translated, because if the
user does type the translated command, their shell is unlikely to execute it
correctly.

Reviewed By: kulshrax

Differential Revision: D17768761

fbshipit-source-id: 4b995382db12397424ef4391e4515bd7933818dd
2019-10-08 14:20:55 -07:00
Jun Wu
224c2cebb3 morestatus: support update --merge state
Summary:
This changes interrupted `update --merge` state from "unfinished merge" state
to "unfinished update" state which messages to get rid of the state.

Reviewed By: sfilipco

Differential Revision: D17766370

fbshipit-source-id: 19ee9277d5067adb44a5c6672527819794e6b2a1
2019-10-08 14:20:54 -07:00
Jun Wu
c3a3b50aaf update: implement --continue
Summary: This gets rid of an interrupted `update --merge` state.

Reviewed By: sfilipco

Differential Revision: D17766372

fbshipit-source-id: 6a697d44ebd1dc4272ebdbe5c4f7e0c124e1a858
2019-10-08 14:20:54 -07:00
Jun Wu
20854aaa90 update: add a state for update --merge
Summary:
Normally `update` does not need some state files. But `update --merge` is a
command that can be interrupted by merge conflicts. Mark it explicitly so
we know how to continue if merge conflict is resolved.

Reviewed By: sfilipco

Differential Revision: D17766371

fbshipit-source-id: 7792b1591edc1fd7ace74833e61d47c06c06bea7
2019-10-08 14:20:53 -07:00
Jun Wu
d1bd38f791 tests: add a test showing suboptimal update --merge UX
Summary: I'm planning to provide `update --continue` to leave the merge state.

Reviewed By: sfilipco

Differential Revision: D17766374

fbshipit-source-id: 51831f65517b4f5859de5990b0d79bb06ccea77b
2019-10-08 14:20:53 -07:00
Jun Wu
5b5e3cbc59 indexedlog: remove "meta" file explicitly from unused logs
Summary:
The recently added test `rotate::tests::test_lookup_rotated` assumes
that the `meta` file in log directories are removed by `try_remove_old_logs`,
because the `meta` file is not opened by the library and is deletable.

However, `try_remove_old_logs` fails to remove `meta`, because it
can fail early trying to remove other files, and skips removing `meta`.

Fix it by always trying to delete `meta` first. This fixes multiple things:
- `rotate::tests::test_lookup_rotated` now passes on Windows.
- `RotateLog::load_log` no longer races with `try_remove_old_logs`.

As we're here, also make sure `try_remove_old_logs` is protected by a lock.

Reviewed By: sfilipco

Differential Revision: D17817355

fbshipit-source-id: 10c0e942807694e4f6b395afe140004ace20b598
2019-10-08 14:00:26 -07:00
Jun Wu
186bdeb1bd hgtime: parse a range
Summary:
`hg` also supports matching a date range via `util.matchdate`. For example,
`Apr 2000` would mean `Apr 1, 2000 0:0:0 to Apr 30, 2000 23:59:59`.

Implement that behavior. Also support other formats covered by `hg help dates`
including `> DATE`, `< DATE`, `DATE to DATE`, and `-DAYS`.

Reviewed By: sfilipco

Differential Revision: D17504706

fbshipit-source-id: db1c280b62a72f4e8128909ca6fd814d85d22491
2019-10-08 11:11:02 -07:00
Jun Wu
785f0040c6 hgtime: parse "ago" time like "5 minutes ago"
Summary:
This is a feature that does not exist in hg. It has potential to unify the
`date` and `ago` revsets.

By using the `humantime` crate we can get this feature fairly easily.

Reviewed By: sfilipco

Differential Revision: D17504705

fbshipit-source-id: b888517114b91c847ae319552d07fe5a5a41cad3
2019-10-08 11:11:02 -07:00
Jun Wu
96c30fbd8a hgtime: parse incomplete dates
Summary:
Dates like `13:00` or `Apr 2010` cannot be parsed directly. Support them by
filling the missing fields.

This is mostly porting from `mercurial.util.parsedate` and
`mercurial.util.strdate`, with a small bug fixed: default value for month/day
are set to "1" instead of "0".

Reviewed By: sfilipco

Differential Revision: D17504703

fbshipit-source-id: dac9f5e4946c8d838f50ef1d4677741f6e4bc771
2019-10-08 11:11:02 -07:00
Jun Wu
4dff8e37f6 hgtime: new crate to work with time, esp for parsing
Summary:
I'd like a native `blackbox`-like command that accepts something like:

  --date 'since 3 hours ago'
  --date 'since yesterday'
  --date today
  --date 'Apr 2019' (implies a range of a month)
  --date 'Apr 2019 to Jul 2019'
  --date '13:00 to 15:00' (implies within today)

With a goal that this can be a superset and replace hg's date utilities,
and it can be used in `log --date`, revsets, etc.

Sadly, none of the top public Rust crates can sasity the existing features
("13:00" implying "today", "Apr 2019" implies a range of a month are two
less-known features that the Rust date utilties do not handle).

So I started porting the Python code (`mercurial.util.parsedate`) to Rust.

The core `parse` function is just 40 lines now.

Reviewed By: sfilipco

Differential Revision: D17504704

fbshipit-source-id: bde356a8cedf3298b060220de499e3954ed9d88b
2019-10-08 11:11:02 -07:00
Jun Wu
4d87019fcb indexedlog: make RotateLog::create_empty_log take lock reference
Summary:
By design, reading is lock-free but writing (including create_empty_log) needs
locks. Make create_empty_log take a lock reference to be more confident.

Reviewed By: xavierd

Differential Revision: D17810952

fbshipit-source-id: 57bf3ea8db691e04de0a083369258f6dbff7c79e
2019-10-08 10:11:56 -07:00
Jun Wu
63f530b6dc indexedlog: add a test about looking up deleted logs in RotateLog
Summary:
With the latest change, logs are lazy. Looking up a deleted log is untested.
Let's add a test.

Reviewed By: xavierd

Differential Revision: D17810951

fbshipit-source-id: 8e0b898636f1c5e71760f00f7df696ac50c5b0f1
2019-10-08 10:11:56 -07:00
Jun Wu
ac7e07dbdf commands: define prefixes as aliases
Summary:
At a recent team meeting we've decided to remove the command prefix matching
behavior, as it can be really annoying for the Rust parser (since it needs to
know all the names, but it wants to avoid spinning up Python). It's even more
annoying for subcommand support. FWIW git does not have prefix matching.

This diff adds various aliases to "roughly" keep the command prefix matching
behavior.

The list of aliases are obtained by this script in `hg dbsh`:

  def unique(prefix, names):
    m = __import__('edenscm.mercurial').mercurial
    try:
      return m.cmdutil.findcmd(prefix, m.commands.table, False)[0][0] in names
    except:
      return False

  nameslist=sorted([i.replace('^','') for i in m.commands.table])
  aliases = {}

  for names in nameslist:
    names = names.split('|')
    for name in names:
      if name.startswith('debug'):
        continue
      for prefix in [name[:i] for i in xrange(1, len(name))]:
        if unique(prefix, names):
          aliases.setdefault(name, []).append(prefix)

Debug commands, and commands that are rarely used are not changed, including:

  'backfillmanifestrevlog': ['backfillm', 'backfillma', 'backfillman', 'backfillmani', 'backfillmanif', 'backfillmanife', 'backfillmanifes', 'backfillmanifest', 'backfillmanifestr', 'backfillmanifestre', 'backfillmanifestrev', 'backfillmanifestrevl', 'backfillmanifestrevlo'],
  'backfilltree': ['backfillt', 'backfilltr', 'backfilltre']}
  'blackbox': ['blac', 'black', 'blackb', 'blackbo'],
  'cachemanifest': ['cac', 'cach', 'cache', 'cachem', 'cachema', 'cacheman', 'cachemani', 'cachemanif', 'cachemanife', 'cachemanifes'],
  'chistedit': ['chi', 'chis', 'chist', 'chiste', 'chisted', 'chistedi'],
  'clone': ['clon'],
  'cloud': ['clou'],
  'convert': ['conv', 'conve', 'conver'],
  'copy': ['cop'],
  'fastannotate': ['fa', 'fas', 'fast', 'fasta', 'fastan', 'fastann', 'fastanno', 'fastannot', 'fastannota', 'fastannotat'],
  'fold': ['fol'],
  'githelp': ['gi', 'git', 'gith', 'githe', 'githel'],
  'histgrep': ['histg', 'histgr', 'histgre'],
  'incoming': ['in', 'inc', 'inco', 'incom', 'incomi', 'incomin'],
  'isbackedup': ['is', 'isb', 'isba', 'isbac', 'isback', 'isbacke', 'isbacked', 'isbackedu'],
  'manifest': ['ma', 'man', 'mani', 'manif', 'manife', 'manifes'],
  'outgoing': ['o', 'ou', 'out', 'outg', 'outgo', 'outgoi', 'outgoin'],
  'prefetch': ['pref', 'prefe', 'prefet', 'prefetc'],
  'prune': ['pru', 'prun'],
  'pushbackup': ['pushb', 'pushba', 'pushbac', 'pushback', 'pushbacku'],
  'rage': ['ra', 'rag'],
  'record': ['recor'],
  'recover': ['recov', 'recove'],
  'redo': ['red'],
  'repack': ['rep', 'repa', 'repac'],
  'reset': ['rese'],
  'rollback': ['rol', 'roll', 'rollb', 'rollba', 'rollbac'],
  'root': ['roo'],
  'serve': ['se', 'ser', 'serv'],
  'share': ['sha', 'shar'],
  'sparse': ['spa', 'spar', 'spars'],
  'svn': ['sv'],
  'undo': ['und'],
  'unshare': ['unsha', 'unshar'],
  'verifyremotefilelog': ['verifyr', 'verifyre', 'verifyrem', 'verifyremo', 'verifyremot', 'verifyremote', 'verifyremotef', 'verifyremotefi', 'verifyremotefil', 'verifyremotefile', 'verifyremotefilel', 'verifyremotefilelo'],

Reviewed By: sfilipco

Differential Revision: D17644676

fbshipit-source-id: f60f5e6810279b52f9a4a1e048eeb529a96bd735
2019-10-08 09:45:59 -07:00
Jun Wu
71b69f8a7e commitcloud: ignore commits not in the repo in revset calculation
Summary: This avoids issues that crashes hg commands.

Reviewed By: sfilipco

Differential Revision: D17792361

fbshipit-source-id: b03b95a2e8448a663025339eeee17582facf897b
2019-10-07 14:59:14 -07:00
Xavier Deguillard
fdc3382c41 sparse: warn on non-existing profiles
Summary:
It's a bit surprising to users that switching to a non-existing profile
triggers a full-checkout. Let's at least warn about it so they can cancel the
operation.

Reviewed By: quark-zju

Differential Revision: D17792720

fbshipit-source-id: 7d91394d3fa439ea1a5715d9a538ea30d3cd6e87
2019-10-07 13:15:16 -07:00
Thomas Orozco
7088442e8d hggit: git_handler: use StringIO.tell(), not pos
Summary: StringIO.pos exists, but cStringIO.pos doesn't. Let's use a method that exists instead!

Reviewed By: xavierd

Differential Revision: D17790697

fbshipit-source-id: 9132a8ca9c0bfc35c0acc573b92399d5fc3f420d
2019-10-07 13:09:36 -07:00
Jun Wu
f1beb0a034 indexedlog: change 'assume_locked' functions to take a lock
Summary:
Suggested by xavierd in D17742002, it's safer to just require a reference to
a lock to prove a lock was taken. So let's make the change.

Reviewed By: xavierd

Differential Revision: D17767455

fbshipit-source-id: c1675a98a60c4874eab0406c59b25603a35a8d83
2019-10-07 12:29:30 -07:00
Jun Wu
c35d8ceaec indexedlog: remove path from ScopedDirLock
Summary: ScopedDirLock does not need path.

Reviewed By: xavierd

Differential Revision: D17767454

fbshipit-source-id: ccafc00081f8eb14bf24534a8cc61e6ad5e794b9
2019-10-07 12:29:30 -07:00
Jun Wu
3d9e9c48d0 indexedlog: add a docstring about public data corruption API
Summary:
Brain-dump why this API exists, and what should new indexedlog internal code do
for new errors.

Reviewed By: xavierd

Differential Revision: D17763339

fbshipit-source-id: b04255a079908f2a80ac49c22cba0da5f1e92539
2019-10-07 12:29:29 -07:00
Jun Wu
ebb19b1a5f indexedlog: Log::sync no longer errors out if meta is missing for read-only path
Summary:
Similar to the previous diff, this makes Log more friendly in case where an external
process runs `rm -rf` brutely.

Reviewed By: xavierd

Differential Revision: D17763340

fbshipit-source-id: 1306e7ecef44f53f7945922b0216ca0a05f45009
2019-10-07 12:29:29 -07:00
Jun Wu
91790bc704 indexedlog: RotateLog::sync no longer errors out if latest is missing for read-only path
Summary:
In rare cases (ex. some other automation runs `rm -rf`), the `latest` file can
get deleted unexpectedly and cause an error. However, if `sync` is expected
to do a read-only refresh to load new data, it is harmless to stay "as-is" if
lastest cannot be read.

Reviewed By: xavierd

Differential Revision: D17763341

fbshipit-source-id: 6a493b8741b628f44709234bd69394d3b4eeb4de
2019-10-07 12:29:29 -07:00
Jun Wu
80124113f3 gc: do not break indexedlog data
Summary:
The code is broken:

- It happily deletes the `rotatelog/latest` file, which is unexpected by RotateLog.
- It can also delete `packs` on Windows, because `\packs\` never matches `/packs/`.

and suboptimal:

- It does unnecessary tests in inner loops.
- It does unnecessary subdir walks.

Fix them.

Reviewed By: singhsrb

Differential Revision: D17777647

fbshipit-source-id: 08afbb1439e36bb5194053e52e1901b538e42ba3
2019-10-07 08:36:47 -07:00
Stanislau Hlebik
cfeedf2c27 add missing newline
Summary:
Before this diff output from two lines was glued:

```
No known server bookmarkssearching for changes
```

Reviewed By: farnz

Differential Revision: D17786686

fbshipit-source-id: ddb96c7fa391f4ca07a18a7a2145fff2b9d249bb
2019-10-07 03:30:28 -07:00
Jun Wu
9c02091449 revisionstore: stop auto recovery on indexedlog errors
Summary:
The auto recovery logic is more harmful than useful as it hides real errors and
can corrupt other running hg processes. Remove them so we can see the real
errors, and since we now have a proper `hg doctor` command that can fix things
more properly.

If this turned out to be an issue, we should investigate why data corruption
happened (they are only expected for force reboot / os crash cases), or add
some configurable auto recovery in the Python layer.

Reviewed By: xavierd

Differential Revision: D17755607

fbshipit-source-id: 0916b65d07da36af6c5aa6d2d6b69fa83d29d530
2019-10-04 20:37:06 -07:00
Jun Wu
bb9d5531ce commands: add a doctor command
Summary: For now it just repairs indexedlog stores. We can add other stuff later.

Reviewed By: xavierd

Differential Revision: D17755606

fbshipit-source-id: 0599ac0e8e5c049f4cf96ae30df53c920dee21a6
2019-10-04 20:37:06 -07:00
Jun Wu
7d013975ca remotefilelog: remove repo.fileslog side effect in reposetup
Summary:
The side effects are undesirable as an error in the store can crash any repo command.
That makes it harder to implement a `doctor` command to fix the stores.

Reviewed By: xavierd

Differential Revision: D17755609

fbshipit-source-id: 3ba1774de965c4d896178adc47df805f6e465071
2019-10-04 20:37:06 -07:00
Jun Wu
8595d3fde8 bindings: add APIs to call into indexedlog-based store repair methods
Summary: This exposes the repair API to the Python world.

Reviewed By: xavierd

Differential Revision: D17755604

fbshipit-source-id: fb5089a1f0648b18d4a338c3c73e939d5ce37bed
2019-10-04 20:37:05 -07:00
Jun Wu
3e99b568eb revisionstore: add repair method on indexedlog-based stores
Summary: This just calls into the indexedlog repair API.

Reviewed By: xavierd

Differential Revision: D17755608

fbshipit-source-id: ff6c99cadfc900f8ab8c49fe887161492e08c692
2019-10-04 20:37:05 -07:00
Jun Wu
0da18952b4 indexedlog: add a repair method for rotate::OpenOptions
Summary:
This runs an explicit "verify & repair" on all logs in a RotateLog and attempt
to fix the "latest" file.

Reviewed By: xavierd

Differential Revision: D17755605

fbshipit-source-id: eaab4a4e76060a4d094e2bbd42baca9f1e684240
2019-10-04 20:37:05 -07:00
Jun Wu
7dff3e1a9d indexedlog: ensure created logs are empty in RotateLog
Summary:
Use the new API `log::OpenOptions::delete_content` to ensure logs are empty.
This auto fixes issues where a stale directory with broken content can prevent
RotateLog from rotating things.

This has some side effects:

- Logs are logically empty but physically have some bytes - test change
- Reveals an integer overflow panic - fixed in logs.rs

Reviewed By: xavierd

Differential Revision: D17741995

fbshipit-source-id: 51904090dad60718deefa537cf4db91554f3ac31
2019-10-04 20:37:04 -07:00
Jun Wu
8160cd590e indexedlog: make logs in RotateLog lazy
Summary:
Previously, RotateLog loads as many logs as it can during initialization or
sync. However, that could be undesirable because loading too many logs can
take time. Make log loading lazy except for the `latest` log to reduce
overhead.

Reviewed By: xavierd

Differential Revision: D17740792

fbshipit-source-id: cde4c1799ed55d390dadaa5bd34f3d2c6d0e1cf7
2019-10-04 20:37:04 -07:00
Jun Wu
3707eea6da indexedlog: add an API to delete log content
Summary: This can be used in LogRotate to ensure new logs being created are empty.

Reviewed By: xavierd

Differential Revision: D17732138

fbshipit-source-id: 57c86e586decf6e26fa7ebe2d74a93afb4559f43
2019-10-04 20:37:04 -07:00
Jun Wu
40a35334bb indexedlog: rewrite Log::repair
Summary:
Fix multiple issues. Namely:
- Move it to OpenOptions, since Log::repair requires a Log, and it's problematic to open a corrupted Log.
- Make it also repair indexes, since otherwise the performance would be terrible.
- Output some human messages about what was done.
- Make it safe (no SIGBUS) by not truncating data. This works because D16076658
  made Log ignore the physical file length, and only use the metadata length.
- Added a strong test which drove a lot of fixes in this stack.

Reviewed By: xavierd

Differential Revision: D17741210

fbshipit-source-id: 9363dc2f38e66df30b5ed0323455bf67b68227c1
2019-10-04 20:37:03 -07:00