2018-02-21 16:55:07 +03:00
|
|
|
#testcases case-innodb case-rocksdb
|
|
|
|
|
|
|
|
#if case-rocksdb
|
|
|
|
$ DBENGINE=rocksdb
|
|
|
|
#else
|
|
|
|
$ DBENGINE=innodb
|
|
|
|
#endif
|
|
|
|
|
2018-01-04 18:22:19 +03:00
|
|
|
$ . "$TESTDIR/hgsql/library.sh"
|
2019-05-28 13:12:27 +03:00
|
|
|
$ setconfig extensions.treemanifest=!
|
2018-09-25 06:39:40 +03:00
|
|
|
$ setconfig hgsql.verbose=1
|
2014-01-29 08:49:56 +04:00
|
|
|
|
|
|
|
# Populate the db with an initial commit
|
|
|
|
|
|
|
|
$ initclient client
|
|
|
|
$ cd client
|
|
|
|
$ echo x > x
|
|
|
|
$ hg commit -qAm x
|
|
|
|
$ cd ..
|
|
|
|
|
|
|
|
$ initserver master masterrepo
|
|
|
|
$ cd master
|
|
|
|
$ hg log
|
|
|
|
$ hg pull -q ../client
|
2018-09-27 02:32:10 +03:00
|
|
|
[hgsql] got lock after * seconds (read 1 rows) (glob)
|
|
|
|
[hgsql] held lock for * seconds (read 5 rows; write 5 rows) (glob)
|
2014-01-29 08:49:56 +04:00
|
|
|
|
|
|
|
$ cd ..
|
|
|
|
|
|
|
|
# Verify new masters see the same commit
|
|
|
|
|
|
|
|
$ initserver master2 masterrepo
|
|
|
|
$ cd master2
|
|
|
|
$ hg log
|
2018-09-25 06:39:40 +03:00
|
|
|
[hgsql] getting 1 commits from database
|
2014-01-29 08:49:56 +04:00
|
|
|
changeset: 0:b292c1e3311f
|
|
|
|
tag: tip
|
|
|
|
user: test
|
|
|
|
date: Thu Jan 01 00:00:00 1970 +0000
|
|
|
|
summary: x
|
|
|
|
|
|
|
|
|
|
|
|
# Push new commit to one master, verify it shows up in the other
|
|
|
|
|
|
|
|
$ cd ../client
|
|
|
|
$ echo y > y
|
2018-04-24 20:56:46 +03:00
|
|
|
|
|
|
|
# (also test for a file containing a single null byte)
|
|
|
|
$ printf '\0' > nullbyte
|
|
|
|
$ f --hexdump nullbyte
|
|
|
|
nullbyte:
|
|
|
|
0000: 00 |.|
|
|
|
|
|
2014-01-29 08:49:56 +04:00
|
|
|
$ hg commit -qAm y
|
|
|
|
$ hg push -q ssh://user@dummy/master
|
|
|
|
$ cd ../master2
|
|
|
|
$ hg log -l 1
|
2018-09-25 06:39:40 +03:00
|
|
|
[hgsql] getting 1 commits from database
|
2018-04-24 20:56:46 +03:00
|
|
|
changeset: 1:b62091368546
|
2014-01-29 08:49:56 +04:00
|
|
|
tag: tip
|
|
|
|
user: test
|
|
|
|
date: Thu Jan 01 00:00:00 1970 +0000
|
|
|
|
summary: y
|
|
|
|
|
2018-04-24 20:56:46 +03:00
|
|
|
$ hg cat -r 1 nullbyte | f --hexdump -
|
|
|
|
|
|
|
|
0000: 00 |.|
|
|
|
|
|
2014-01-29 08:49:56 +04:00
|
|
|
# Push a bookmark to one master, verify in the other
|
|
|
|
|
|
|
|
$ cd ../client
|
|
|
|
$ hg book mybook
|
|
|
|
$ hg push ssh://user@dummy/master -B mybook
|
|
|
|
pushing to ssh://user@dummy/master
|
|
|
|
searching for changes
|
|
|
|
no changes found
|
2018-09-27 02:32:10 +03:00
|
|
|
remote: [hgsql] got lock after * seconds (read 1 rows) (glob)
|
2019-04-13 13:16:30 +03:00
|
|
|
remote: [hgsql] held lock for * seconds (read 5 rows; write 1 rows) (glob)
|
2014-01-29 08:49:56 +04:00
|
|
|
exporting bookmark mybook
|
|
|
|
[1]
|
|
|
|
$ cd ../master2
|
|
|
|
$ hg book
|
2018-09-25 06:39:40 +03:00
|
|
|
[hgsql] getting 0 commits from database
|
2018-04-24 20:56:46 +03:00
|
|
|
mybook 1:b62091368546
|
2014-01-29 08:49:56 +04:00
|
|
|
|
|
|
|
# Pull commit and bookmark to one master, verify in the other
|
|
|
|
|
|
|
|
$ cd ../client
|
|
|
|
$ hg up mybook
|
|
|
|
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
|
|
|
$ echo z > z
|
|
|
|
$ hg commit -qAm z
|
|
|
|
$ cd ../master
|
|
|
|
$ hg pull -q ssh://user@dummy/client
|
2018-09-27 02:32:10 +03:00
|
|
|
[hgsql] got lock after * seconds (read 1 rows) (glob)
|
2019-04-13 13:16:30 +03:00
|
|
|
[hgsql] held lock for * seconds (read 8 rows; write 9 rows) (glob)
|
2014-01-29 08:49:56 +04:00
|
|
|
$ cd ../master2
|
|
|
|
$ hg log -l 1
|
2018-09-25 06:39:40 +03:00
|
|
|
[hgsql] getting 1 commits from database
|
2018-04-24 20:56:46 +03:00
|
|
|
changeset: 2:f3a7cb746fa9
|
2014-01-29 08:49:56 +04:00
|
|
|
bookmark: mybook
|
|
|
|
tag: tip
|
|
|
|
user: test
|
|
|
|
date: Thu Jan 01 00:00:00 1970 +0000
|
|
|
|
summary: z
|
|
|
|
|
2017-03-30 00:47:53 +03:00
|
|
|
# Delete a bookmark in one, verify in the other
|
|
|
|
|
|
|
|
$ hg book book1
|
2018-09-27 02:32:10 +03:00
|
|
|
[hgsql] got lock after * seconds (read 1 rows) (glob)
|
2019-04-13 13:16:30 +03:00
|
|
|
[hgsql] held lock for * seconds (read 6 rows; write 1 rows) (glob)
|
2017-03-30 00:47:53 +03:00
|
|
|
$ cd ../master
|
|
|
|
$ hg book
|
2018-09-25 06:39:40 +03:00
|
|
|
[hgsql] getting 0 commits from database
|
2017-03-30 00:47:53 +03:00
|
|
|
book1 -1:000000000000
|
2018-04-24 20:56:46 +03:00
|
|
|
mybook 2:f3a7cb746fa9
|
2017-03-30 00:47:53 +03:00
|
|
|
$ hg book -d book1
|
2018-09-27 02:32:10 +03:00
|
|
|
[hgsql] got lock after * seconds (read 1 rows) (glob)
|
2019-04-13 13:16:30 +03:00
|
|
|
[hgsql] held lock for * seconds (read 7 rows; write 1 rows) (glob)
|
2017-03-30 00:47:53 +03:00
|
|
|
$ cd ../master2
|
|
|
|
$ hg book
|
2018-09-25 06:39:40 +03:00
|
|
|
[hgsql] getting 0 commits from database
|
2018-04-24 20:56:46 +03:00
|
|
|
mybook 2:f3a7cb746fa9
|
2017-03-30 00:47:53 +03:00
|
|
|
|
2014-10-27 23:56:13 +03:00
|
|
|
# Verify that --forcesync works
|
|
|
|
|
2016-10-13 19:47:40 +03:00
|
|
|
$ cd ../
|
|
|
|
$ cp $HGRCPATH backup.hgrc
|
|
|
|
$ cd master
|
2014-10-27 23:56:13 +03:00
|
|
|
$ echo '[hooks]' >> $HGRCPATH
|
Make forcesync only acquire local repo lock
Summary:
Previously, the --forcesync flag would cause the command to acquire the
sqllock, which would mean a read only command would block for any ongoing write
commands to complete, which is undesirable. Now, we will wait for the lcoal repo
lock only, instead of skipping the sync as we did before the initial patch.
This ensures that forcesync operations will see all committed changes, but won't
wait for ongoing write transactions from other masters.
Test Plan: updated test
Reviewers: sid0, davidsp, pyd, mpm, durham
Reviewed By: durham
Differential Revision: https://phabricator.fb.com/D1682970
Signature: t1:1682970:1416014352:e7f3daa09e79abd43a16c8eb74bc69272d73c83d
2014-11-14 21:53:35 +03:00
|
|
|
$ echo 'presyncdb=$TESTTMP/hook.sh' >> $HGRCPATH
|
2015-11-18 00:29:21 +03:00
|
|
|
$ echo 'sleep 2' > $TESTTMP/hook.sh
|
2014-10-27 23:56:13 +03:00
|
|
|
$ chmod a+x $TESTTMP/hook.sh
|
|
|
|
$ cd ../client
|
|
|
|
$ echo a > a
|
|
|
|
$ hg commit -qAm a
|
Make forcesync only acquire local repo lock
Summary:
Previously, the --forcesync flag would cause the command to acquire the
sqllock, which would mean a read only command would block for any ongoing write
commands to complete, which is undesirable. Now, we will wait for the lcoal repo
lock only, instead of skipping the sync as we did before the initial patch.
This ensures that forcesync operations will see all committed changes, but won't
wait for ongoing write transactions from other masters.
Test Plan: updated test
Reviewers: sid0, davidsp, pyd, mpm, durham
Reviewed By: durham
Differential Revision: https://phabricator.fb.com/D1682970
Signature: t1:1682970:1416014352:e7f3daa09e79abd43a16c8eb74bc69272d73c83d
2014-11-14 21:53:35 +03:00
|
|
|
$ hg push -q ssh://user@dummy/master2
|
|
|
|
$ cd ../master
|
|
|
|
$ hg log -l 1 --template '{rev} {desc}\n' &
|
2015-11-18 00:29:21 +03:00
|
|
|
$ sleep 1
|
2018-09-25 06:39:40 +03:00
|
|
|
[hgsql] getting 1 commits from database
|
Make forcesync only acquire local repo lock
Summary:
Previously, the --forcesync flag would cause the command to acquire the
sqllock, which would mean a read only command would block for any ongoing write
commands to complete, which is undesirable. Now, we will wait for the lcoal repo
lock only, instead of skipping the sync as we did before the initial patch.
This ensures that forcesync operations will see all committed changes, but won't
wait for ongoing write transactions from other masters.
Test Plan: updated test
Reviewers: sid0, davidsp, pyd, mpm, durham
Reviewed By: durham
Differential Revision: https://phabricator.fb.com/D1682970
Signature: t1:1682970:1416014352:e7f3daa09e79abd43a16c8eb74bc69272d73c83d
2014-11-14 21:53:35 +03:00
|
|
|
$ hg log -l 1 --template '{rev} {desc}\n' --forcesync
|
2015-10-27 01:48:14 +03:00
|
|
|
waiting for lock on working directory of $TESTTMP/master held by * (glob)
|
2018-08-23 07:26:50 +03:00
|
|
|
(hint: run 'hg debugprocesstree *' to see related processes) (glob)
|
Make forcesync only acquire local repo lock
Summary:
Previously, the --forcesync flag would cause the command to acquire the
sqllock, which would mean a read only command would block for any ongoing write
commands to complete, which is undesirable. Now, we will wait for the lcoal repo
lock only, instead of skipping the sync as we did before the initial patch.
This ensures that forcesync operations will see all committed changes, but won't
wait for ongoing write transactions from other masters.
Test Plan: updated test
Reviewers: sid0, davidsp, pyd, mpm, durham
Reviewed By: durham
Differential Revision: https://phabricator.fb.com/D1682970
Signature: t1:1682970:1416014352:e7f3daa09e79abd43a16c8eb74bc69272d73c83d
2014-11-14 21:53:35 +03:00
|
|
|
3 a
|
2018-09-26 02:04:12 +03:00
|
|
|
got lock after * seconds (glob)
|
2014-10-27 23:56:13 +03:00
|
|
|
3 a
|
2016-10-13 19:47:40 +03:00
|
|
|
$ cd ..
|
|
|
|
$ cp backup.hgrc $HGRCPATH
|
|
|
|
|
|
|
|
# Update one bookmark but not the other
|
|
|
|
$ cat >> $TESTTMP/inspectsql.py <<EOF
|
|
|
|
> import os, sys
|
2019-01-30 03:25:33 +03:00
|
|
|
> from edenscm.mercurial import demandimport, extensions
|
2016-10-13 19:47:40 +03:00
|
|
|
> with demandimport.deactivated():
|
|
|
|
> import mysql.connector
|
|
|
|
> watchstrings = os.environ.get("INSPECTSQL")
|
|
|
|
> if watchstrings:
|
|
|
|
> watchstrings = watchstrings.split(',')
|
|
|
|
> def printsql(orig, *args, **kwargs):
|
|
|
|
> if not watchstrings or any(s for s in watchstrings if s in args[1]):
|
|
|
|
> print >> sys.stderr, args[1] % args[2]
|
|
|
|
> return orig(*args, **kwargs)
|
|
|
|
> extensions.wrapfunction(mysql.connector.cursor.MySQLCursor, "execute", printsql)
|
|
|
|
> EOF
|
|
|
|
$ cat >> $HGRCPATH <<EOF
|
|
|
|
> [extensions]
|
|
|
|
> inspectsql=$TESTTMP/inspectsql.py
|
|
|
|
> EOF
|
|
|
|
$ cd master
|
|
|
|
$ INSPECTSQL=DELETE,INSERT hg book mybook2
|
2018-09-27 02:32:10 +03:00
|
|
|
[hgsql] got lock after * seconds (read 1 rows) (glob)
|
2016-10-13 19:47:40 +03:00
|
|
|
INSERT INTO revision_references(repo, namespace, name, value) VALUES (masterrepo, 'bookmarks', mybook2, 0000000000000000000000000000000000000000)
|
2018-06-27 01:03:59 +03:00
|
|
|
INSERT INTO revision_references(repo, namespace, name, value) VALUES(masterrepo, 'tip', 'tip', 3) ON DUPLICATE KEY UPDATE value=3
|
2019-04-13 13:16:30 +03:00
|
|
|
[hgsql] held lock for * seconds (read 6 rows; write 1 rows) (glob)
|
2016-10-13 19:47:40 +03:00
|
|
|
$ cd ..
|
|
|
|
$ cp backup.hgrc $HGRCPATH
|