douban / code

[DEPRECATED]Douban CODE

Home Page:http://douban-code.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Broken pipe when push to master

itxx00 opened this issue · comments

Hello,在创建了第一个repo之后,我按照步骤进行git push origin master操作,但是等待一段时间后失败,在服务端看到的错误输出信息如下:

Unpacking objects: 100% (3/3), done.
2014-02-18 15:03:31 [5079] [CRITICAL] WORKER TIMEOUT (pid:5105) 
2014-02-18 15:03:31 [5128] [INFO] Booting worker with pid: 5128
Did not install docutils
fatal: write error: Broken pipe

在客户端看到的信息如下:

]$ git push origin master
Counting objects: 5, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 261 bytes, done.
Total 3 (delta 1), reused 0 (delta 0)
error: RPC failed; result=52, HTTP code = 0

@itxx00 能在详细一点么,比如说你的code代码的版本,执行的命令是什么?

我使用的code是master分支commit 648a635 ,服务端启动命令:gunicorn -w 1 -b 0.0.0.0:80 app:app
客户端操作命令:git push -u origin master

@xtao 另外我还修改了code/config.py中的DOMAIN为DOMAIN = "http://0.0.0.0:80/"

应该是 DOMAIN = "http://0.0.0.0:80/" 的问题,你改为 DOMAIN = "http://127.0.0.1:80/" 吧

8080之类大于8000的端口号是不是好些?80还得sudo
2014/02/18 15:29 "xingxing" notifications@github.com:

@xtao https://github.com/xtao 另外我还修改了code/config.py中的DOMAIN为DOMAIN = "
http://0.0.0.0:80/"


Reply to this email directly or view it on GitHubhttps://github.com//issues/22#issuecomment-35359099
.

2014-02-18 15:49 GMT+08:00 Xu Tao notifications@github.com:

应该是 DOMAIN = "http://0.0.0.0:80/" 的问题,你改为 DOMAIN = "http://127.0.0.1:80/"


Reply to this email directly or view it on GitHubhttps://github.com//issues/22#issuecomment-35360134
.

我修改成了默认的设置127.0.0.1:8000,然后另外安装了一个nginx来反向代理到code的8000端口,再另外一台机器上做push操作时仍然是这个问题。

是因为你的项目太大了, 第一次commit把整个项目推上去(默认好像是1M), 试一试涨到500M:

git config --global http.postBuffer 524288000

@小明 项目不大啊,只有一个README.md ,我也设置过了buffer大小的,还是不行啊。
这是我的操作记录,https://asciinema.org/a/7700 ,不知道是哪里弄错了啊。

@xtao @itxx00 @qingfeng 这确实是个问题. 我观察了下,大概原因是gunicorn默认的worker_class是sync, 刚才研究下是在POST /USER/XXX.git/git-receive-pack和执行git服务器的hook post_receive之间发生的阻塞.

@itxx00 你可以尝试:

gunicorn -b 0.0.0.0:8000 app:app  -k gevent 
#或者
gunicorn -b 0.0.0.0:8000 app:app -k eventlet

PS:当然需要你先安装gevent.

@xtao @qingfeng worker默认超时30s, 所以worker卡了一会就死掉换了新的.刚才试了一下tornado类型也是阻塞的.具体原因可能你们更了解,我把hook移走就没事了. 我想是urllib2.urlopen是阻塞操作的原因

@dongweiming 是在git push的时候,会有一个2个并发请求,我的理解2个worker可以handle的了这个并发,所以后来gunicorn加了一个-w 2的参数,我之前的测试是可以实现的。

@xtao 额 是这样的.可以再README里面有个说明, 然后我觉得这个问题还是问题:解决并发处理为非阻塞模式

@xutao 现在sina解决了这个问题么

@dongweiming 这个不是 sina 的问题,是 worker 的并发模型的问题,默认开启一个 sync worker 处理请求时,这个 worker 再访问同一个 worker 的时候会有问题,(其实就是自己访问了自己),增加 worker 或者改成 async 会有改善。

这个访问是写在了 post-receive hook 里面,这个机制没有改过,所以 push 的时候,会在有一次的访问。
之前 async 的时候是阻塞的,因为 subprocess 没有用 gevent patch 过的,后来修了一下这个问题,已经使用的是 gevent patch 的了。理论上应该修正了,但是我没有测试过。

看了眼代码,sina 还是旧的版本,我来升级一下。