Commit Graph

138 Commits

Author SHA1 Message Date
Durham Goode
a109789413 Move addchangegroup to match Mercurial upstream
localrepository.addchangegroup got moved to changegroup.addchangegroup in
upstream Mercurial. So we need to move it accordingly.
2014-04-09 10:56:53 -07:00
Durham Goode
a3a66d460a Hide mysql warning when updating a row with multiple unique keys
The revision_references table has multiple unique keys (primary key, and a unique
name index). Using ON DUPLICATE KEY in an INSERT causes a warning, since it will
only update one of the rows, even if there are two duplicates. We can safely
ignore this since we know there will only ever be one row that has a duplicate
key.
2014-03-19 13:06:20 -07:00
Durham Goode
40472c5f28 Allow local commits 2014-03-13 12:42:20 -07:00
Durham Goode
d64b28c7f5 Verify write lock before writing to db
Check with the actual database to ensure we are the ones with the write lock
before performing the actual lock. We encountered an issue previously where two
writers managed to write at once, which this should now catch.
2014-03-12 12:52:27 -07:00
Durham Goode
d355928627 Switch to a single write_lock for commits and bookmarks 2014-03-12 12:35:04 -07:00
Durham Goode
8059a8f932 Take bookmark lock for duration of pulls
Summary:
In certain pull use cases (hg pull -B foo), it tries to update the bookmarks
outside of the normal bookmark.updatefromremote() function. This takes the lock
at the very beginning of the pull so all inner bookmark manipulations should
succeed.

Test Plan:
Ran the new test with and without the fix, verified it failed before
and passed afterwards.

Reviewers: sid0, davidsp

Differential Revision: https://phabricator.fb.com/D1214148
2014-03-11 11:25:23 -07:00
Durham Goode
75f687460a Replace (path,rev,chunk) IN (....) query since it didn't use an index
It turns out mysql doesn't optimize '(a,b,c) IN ((x,y,z),(m,n,o),...)' queries,
so we want to avoid using them.
2014-03-10 14:52:31 -07:00
Durham Goode
e35323e658 Make the waittimeout configurable 2014-03-07 16:29:09 -08:00
Durham Goode
0f98887c95 Fix pushing and pulling bookmarks from local repos
Pushing and pulling local bookmarks was a bit broken, since as soon as the
bookmark dict tried to write, it would sync with the db, which overwrote the
current bookmarks.

This changes it to require the sql connection to be set up and locked before
the bookmark modifications even start to happen.
2014-02-18 17:16:45 -08:00
Durham Goode
f7cb418f63 Fix pushing and pulling from a local repo 2014-02-18 15:59:46 -08:00
Durham Goode
8e1cbbb098 Don't block readonly operations when the repo needs updating
Previously, if the repo needed to be synced, every command would block and
wait until the repo was synced.  So if one command was doing the update, all
the other parallel commands (even the readonly ones) would be blocked.

This changes it so readonly commands (i.e. commands that don't require locking
the db) can be executed even if the repo is slightly out of date. The downside
of this is a user may get a slightly old (by seconds) version of the repo when
doing a pull.
2014-02-06 14:39:57 -08:00
Durham Goode
ff40ebb1ef Add test for reordering linkrevs 2014-02-03 17:00:26 -08:00
Durham Goode
3bee69cba0 Rename pushkeys table to revision_references 2014-02-03 14:18:38 -08:00
Durham Goode
d078c14d13 Add make/setup files 2014-02-03 10:51:06 -08:00
Durham Goode
22bfad4b6f Add tests
Adds test to test synchronizing between master repos and to test the
prevention of non-push/pull transactions (such as commit and strip).

Adds tests/getdb.sh to the ignored list. This is a script that provides the
database host, port, and name for the test. It must be in the form
"ip:port:databasename". The test assumes that the database name is unique and
doesn't already exist each time getdb.sh is called.
2014-01-28 20:49:56 -08:00
Durham Goode
3cb8d47272 Fix pushing bookmarks
Bookmarks were failing to write to the database when pushed (but worked fine
when pulled) because the executewithsql around the bookmark writing would sync
the bookmark dict and overwrite the pending bookmarks.

The new logic takes the lock up at the pushkey level. Also had to add support
for nesting locks so both the pushkeys and the bookmark write could take the
bookmarks_lock.
2014-01-28 20:46:23 -08:00
Durham Goode
bc08b5e4b9 Add comments around rev reordering 2014-01-27 18:50:24 -08:00
Durham Goode
32863d5aa7 General clean up and maxrowsize configuration
Fixes up some comments and function descriptions.

Adds hgsql.maxrowsize configuration option with a default value of 1MB.
2014-01-23 19:22:49 -08:00
Durham Goode
bfe1b6458d Add configuration for a maximum transaction size
MySQL has limits on how large a transaction can become, so if a commit is
larger than that we need to break it into several database transactions. To
keep the atomic nature of the repo table, we add a new pushkey namespace 'tip'
that contains the latest valid linkrev for that repo in the table. Then at the
very end we update the 'tip' marker (along with the heads).

When syncing, the repo only syncs up to the tip commit.

When making a commit, it first cleans up any abandon commits by deleting
any rows that have a linkrev greater than the tip.
2014-01-23 18:40:55 -08:00
Durham Goode
8ab51eaa9f Add pending revision validation
Before writing revisions to the database we now validate that they are
correct. This consists of two checks:

1. Are we appending to the same linkrev in the database as we are in the local
repo.
2. Every rev that we are writing to the database has a base, p1, and p2 rev
dependency. Before we write the rev, verify that the base, p1, and p2 revs in
the database have the same nodes as in the localrepo. This prevents us from
writing rev dependencies that then point at the incorrect node (due to
different ordering in the db vs local).
2014-01-21 16:09:08 -08:00
Durham Goode
9f0b718461 Allow nested connections
When performing a pull it does the commits, then the bookmarks. This change
allows the sql connections to become nested, enabling that.
2014-01-21 16:06:25 -08:00
Durham Goode
97167ab6c4 Add node information to revisions table
In order to validate that the incoming revisions are valid, we need node
information in the revisions table. A future patch will add the actual
validation.
2014-01-21 16:05:27 -08:00
Durham Goode
6e3be66ba0 Add more verification during syncs
Check that heads and bookmarks match after syncing.
Verify that the new commits are being applied on top of the correct linkrev on
the server.
Remove excess invalidate steps. They are no longer necessary since we do the
lock.release() much later in the process (which was what caused problems
originally).
2014-01-03 12:03:52 -08:00
Durham Goode
52fa7e03b2 Wrap revlog._writeentry instead of intercepting
I added revlog._writeentry to upstream Mercurial which allows us to easily
intercept revlog writes instead of building crazy file-like objects to
intercept the calls.
2014-01-03 12:01:50 -08:00
Durham Goode
0ed408193a Refactor sql transactions to a single function
Moves the sql connect, lock, unlock, close logic to a single executewithsql
function so all the complicated try/finally logic is in one place.

Move pre-transaction close logic out of the hook and into a transaction.close
wrapper. This makes it more symettrical (matches transaction open/close) and
allows hooks to fail the transaction before the db commit.
2014-01-02 12:19:50 -08:00
Durham Goode
b287ed5fb6 Use a single table for many repos
Switches to using a single table for many repos instead of multiple databases.

Changes the headbookmarks table to be a pushkeys table using the pushkeys
namespace convention.
2014-01-02 11:06:45 -08:00
Durham Goode
64af581fa1 Fix error with transaction offsets, plus a bunch of tweaks 2013-12-10 19:00:55 -08:00
Durham Goode
a30ef476ad Catch sql unlock errors, so they don't hide real errors 2013-11-27 11:16:45 -08:00
Durham Goode
83eee89448 Get rid of global variables
Create sqllocalrepo class that manages the sql connection
2013-11-21 12:32:05 -08:00
Durham Goode
fc39c7a376 Increase mysql idle timeout to 5 minutes
Move public phase boundary forward during sync
Thread syncdb so we pull from the db at the same time we are writing to the
revlogs. Also use a buffered revlog so we only flush at the very end.
Clear repo._filecache after syncing in order to force the changelog to update.
2013-10-31 10:37:49 -07:00
Durham Goode
43a7de50fb Split large files into multiple records 2013-10-30 13:41:33 -07:00
Durham Goode
5baeae4cf4 Add revisions in linkrev order 2013-10-29 15:55:43 -07:00
Durham Goode
384d770abd Add sqlrecover command
Add createdtime to revs table
Allow pulls into the repo
2013-10-29 12:55:14 -07:00
Durham Goode
3501e57b92 Add revlog validation and fix transaction truncating 2013-10-28 18:57:18 -07:00
Durham Goode
91f0ca4206 Enable bookmark/head sync 2013-10-28 16:09:47 -07:00
Durham Goode
1b6e441663 Fix path bug and fix i/d files 2013-10-17 17:15:41 -07:00
Durham Goode
ec4bd7e3d9 Add transaction hooks and attempt to get .d working 2013-10-17 16:47:34 -07:00
Durham Goode
cedf7a6d6e Initial prototype 2013-10-17 16:46:12 -07:00