2019-12-10 02:24:31 +03:00
|
|
|
#chg-compatible
|
|
|
|
|
2018-09-26 02:04:12 +03:00
|
|
|
Test hgsql tries to sync before entering the critical section
|
|
|
|
|
|
|
|
$ . "$TESTDIR/hgsql/library.sh"
|
2020-01-20 13:42:49 +03:00
|
|
|
$ disable treemanifest
|
2018-09-26 02:04:12 +03:00
|
|
|
$ setconfig hgsql.verbose=1
|
|
|
|
|
|
|
|
$ newrepo state1
|
|
|
|
$ hg debugdrawdag << 'EOS'
|
|
|
|
> B
|
|
|
|
> |
|
|
|
|
> A
|
|
|
|
> EOS
|
|
|
|
|
|
|
|
$ newrepo state2
|
|
|
|
$ hg debugdrawdag << 'EOS'
|
|
|
|
> C
|
|
|
|
> |
|
|
|
|
> B
|
|
|
|
> |
|
|
|
|
> A
|
|
|
|
> EOS
|
|
|
|
|
|
|
|
$ newrepo state3
|
|
|
|
$ hg debugdrawdag << 'EOS'
|
|
|
|
> D
|
|
|
|
> |
|
|
|
|
> C
|
|
|
|
> |
|
|
|
|
> B
|
|
|
|
> |
|
|
|
|
> A
|
|
|
|
> EOS
|
|
|
|
|
|
|
|
$ newrepo state4
|
|
|
|
$ hg debugdrawdag << 'EOS'
|
|
|
|
> E
|
|
|
|
> |
|
|
|
|
> D
|
|
|
|
> |
|
|
|
|
> C
|
|
|
|
> |
|
|
|
|
> B
|
|
|
|
> |
|
|
|
|
> A
|
|
|
|
> EOS
|
|
|
|
|
|
|
|
$ cd $TESTTMP
|
|
|
|
$ initserver repo1 master
|
|
|
|
$ initserver repo2 master
|
|
|
|
$ initserver repo3 master
|
|
|
|
$ initserver repo4 master
|
|
|
|
|
|
|
|
Repo1: 2 commits. Sync them to the database.
|
|
|
|
|
|
|
|
$ cd $TESTTMP/repo1
|
|
|
|
$ hg pull -r tip $TESTTMP/state1
|
2018-09-27 02:32:10 +03:00
|
|
|
[hgsql] got lock after * seconds (read 1 rows) (glob)
|
2018-09-26 02:04:12 +03:00
|
|
|
pulling from $TESTTMP/state1
|
|
|
|
adding changesets
|
|
|
|
adding manifests
|
|
|
|
adding file changes
|
|
|
|
added 2 changesets with 2 changes to 2 files
|
2019-12-17 05:10:38 +03:00
|
|
|
adding remote bookmark A
|
|
|
|
adding remote bookmark B
|
|
|
|
[hgsql] held lock for * seconds (read 5 rows; write 10 rows) (glob)
|
2018-09-26 02:04:12 +03:00
|
|
|
|
|
|
|
Repo2: Emulate client push. Hold the lock for long.
|
|
|
|
|
|
|
|
$ cd $TESTTMP/repo2
|
|
|
|
$ hg --config hooks.pretxnclose.dely='sleep 6' pull -r tip $TESTTMP/state2 &>out &
|
|
|
|
$ disown
|
|
|
|
|
|
|
|
Repo 3: Emulate client push to sql, after repo2.
|
|
|
|
|
|
|
|
$ sleep 2
|
|
|
|
$ cd $TESTTMP/repo3
|
|
|
|
$ hg --config hooks.pretxnclose.dely='sleep 6' pull -r tip $TESTTMP/state3 &>out &
|
|
|
|
$ disown
|
|
|
|
|
|
|
|
Emulate writing to another repo when the lock was held elsewhere.
|
|
|
|
Explaination:
|
|
|
|
- The first "getting 2 commits from database" is because repo4 is empty, and the database has A,B synced from repo1.
|
|
|
|
- The second "getting 1 commits from database" is because repo2 push completes.
|
|
|
|
- The third "getting 1 commits from database" is because repo3 push completes.
|
|
|
|
|
|
|
|
$ cd $TESTTMP/repo4
|
|
|
|
$ setconfig hgsql.syncinterval=0.1 hgsql.debugminsqllockwaittime=13
|
|
|
|
$ hg pull -r tip $TESTTMP/state4
|
|
|
|
[hgsql] getting 2 commits from database
|
|
|
|
[hgsql] getting 1 commits from database
|
|
|
|
[hgsql] getting 1 commits from database
|
2018-09-27 02:32:10 +03:00
|
|
|
[hgsql] got lock after * seconds (read * rows) (glob)
|
2018-09-26 02:04:12 +03:00
|
|
|
pulling from $TESTTMP/state4
|
|
|
|
searching for changes
|
|
|
|
adding changesets
|
|
|
|
adding manifests
|
|
|
|
adding file changes
|
|
|
|
added 1 changesets with 1 changes to 1 files
|
2019-12-17 05:10:38 +03:00
|
|
|
adding remote bookmark E
|
|
|
|
[hgsql] held lock for * seconds (read * rows; write 8 rows) (glob)
|
2018-09-26 02:04:12 +03:00
|
|
|
|
|
|
|
Make sure repo2 and repo3 log looks sane.
|
|
|
|
|
|
|
|
$ cat $TESTTMP/repo2/out
|
|
|
|
[hgsql] getting 2 commits from database
|
2018-09-27 02:32:10 +03:00
|
|
|
[hgsql] got lock after * seconds (read 1 rows) (glob)
|
2018-09-26 02:04:12 +03:00
|
|
|
pulling from $TESTTMP/state2
|
|
|
|
searching for changes
|
|
|
|
adding changesets
|
|
|
|
adding manifests
|
|
|
|
adding file changes
|
|
|
|
added 1 changesets with 1 changes to 1 files
|
2019-12-17 05:10:38 +03:00
|
|
|
adding remote bookmark C
|
|
|
|
[hgsql] held lock for * seconds (read 9 rows; write 8 rows) (glob)
|
2018-09-26 02:04:12 +03:00
|
|
|
|
|
|
|
$ cat $TESTTMP/repo3/out
|
|
|
|
[hgsql] getting 2 commits from database
|
2018-09-27 02:32:10 +03:00
|
|
|
[hgsql] got lock after * seconds (read 1 rows) (glob)
|
2018-09-26 02:04:12 +03:00
|
|
|
[hgsql] getting 1 commits from database
|
|
|
|
pulling from $TESTTMP/state3
|
|
|
|
searching for changes
|
|
|
|
adding changesets
|
|
|
|
adding manifests
|
|
|
|
adding file changes
|
|
|
|
added 1 changesets with 1 changes to 1 files
|
2019-12-17 05:10:38 +03:00
|
|
|
adding remote bookmark D
|
|
|
|
[hgsql] held lock for * seconds (read 10 rows; write 8 rows) (glob)
|