竞争条件,如果两个客户git svn rebase和git推到相同的git回购? [英] race conditions if two clients git svn rebase and git push to the same git repo?

查看:106
本文介绍了竞争条件,如果两个客户git svn rebase和git推到相同的git回购?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果两个客户端都尝试svn-rebase并同时推送,svn是否可以从多个客户端重新绑定到相同的Git仓库?

以下是更多信息:我正在设置SVN项目的GitHub托管镜像。为了完成镜像,我将每隔几分钟运行一次这个cron作业(每个本文):

  git svn rebase 
git.exe push origin master

为了实现冗余,我想让另一台服务器运行相同的cron作业。但是,面对这样的竞争条件,这会打破吗?


  • 几乎在同一时间,两台服务器都发生重新分层。一个将 git push 更改,另一个将尝试推进相同的更改。
  • 一台服务器重新绑定,然后是SVN签入,然后另一台服务器重新绑定,并迅速推入新的签入,然后第一个较慢的服务器尝试推入一个签入。



这是如果后面的操作简单地返回一个无操作(又名一切最新),那么这是期望的。如果冲突推送失败也是可以的,只要它的cron作业稍后在非冲突的tmie中运行,那么它就可以正常工作。



什么是不好的是否这两个服务器上的本地回购可能会进入需要手动干预的失败状态。如果这种失败是可能的,我应该如何改变上面的命令以使它们自我恢复?

不要以为你会遇到任何特殊的问题。默认情况下,使用Git推入裸仓库不允许非快速前进推送,因此如果出现任何类型的冲突,那么推送将暂时失败。 (下一个,如果当时没有冲突,就会成功)。

这些情况应该很容易让你手动测试,通过运行如下的序列:

 实例A实例B 
---------- --------- -
git svn rebase
git svn rebase
git push
git push

 实例B实例B 
---------- - ---------
git svn rebase
git svn rebase
git push
git push


Is svn-rebasing-and-pushing from multiple clients to the same Git repo vulnerable to race conditions if both clients try to svn-rebase and push concurrently?

Here's more info: I'm setting up a GitHub-hosted mirror of an SVN project. To do the mirroring, I'll run this cron job every few minutes (per this article):

git svn rebase
git.exe push origin master

For redundancy, I'd like to have another server running the same cron job. But will this break in the face of race conditions like these?

  • Both servers rebase at almost the same time. One will git push the changes and the other will try to push the same changes.
  • One server rebases, then there's an SVN checkin, then the other server rebases and quickly pushes the new checkin, then the first, slower server tries to push one checkin behind.

It's desired if the later operation simply returns a no-op (aka "Everything up-to-date"). It's also OK if the conflicting push fails, as long as if its cron job runs again later at a non-conflicting tmie, then it will work OK.

What's not OK is if the local repo on either server can get into a failed state where manual intervention is needed. If that kind of failure is possible, how should I change the commands above to make them self-recovering?

解决方案

I don't think you will run into any particular problems doing this. Pushing into a bare repository with Git by default disallows non-"fast-foward" pushes, so if there were to be any kind of conflict then that push would fail temporarily. (The next one, if there is no conflict at that time, would succeed.)

These situations should be easy for you to test manually, by running sequences like:

Instance A            Instance B
----------            ----------
git svn rebase
                      git svn rebase
git push
                      git push

and

Instance A            Instance B
----------            ----------
git svn rebase
                      git svn rebase
                      git push
git push

这篇关于竞争条件,如果两个客户git svn rebase和git推到相同的git回购?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆