[精讚] [會員登入]
1706

[GITLAB] 解決git使用http/https clone或pull時在大小達1G時的斷線問題

git clone大專案時出現RPC failed; curl 18 transfer closed with outstanding read data remaining的錯誤,如何解決?

分享此文連結 //n.sfs.tw/16335

分享連結 [GITLAB] 解決git使用http/https clone或pull時在大小達1G時的斷線問題@新精讚
(文章歡迎轉載,務必尊重版權註明連結來源)
2024-01-21 12:01:05 最後編修
2024-01-21 03:08:45 By 張○○
 

事情是這樣的,我建了一個gitlab,平時就把寫的程式丟上去。

今天有一個移機的需求,這個專案很大,大約有10G的大小。

每當我在git pull 或是 clone 這個專案的時候,就出現了錯誤,如下面的橘色文字

# git pull http://example.com/myname/project.git
Username for 'http://example.com': myname
Password for 'http://myname@example.com':<打入密碼>
remote: Enumerating objects: 89044, done.
remote: Counting objects: 100% (632/632), done.
remote: Compressing objects: 100% (631/631), done.
Receiving objects:  5% (5245/89044), 0.60 GiB | 10.08 MiB/s  <== 這個會一直跳動直到出錯
error: RPC failed; curl 18 transfer closed with outstanding read data remaining
error: 2803 bytes of body are still expected
fetch-pack: unexpected disconnect while reading sideband packet
fatal: early EOF
fatal: fetch-pack: invalid index-pack output

當我試著去搜尋這個錯誤的解決方法時我得到以下的建議[1][2][3[4]]

git config --global http.postBuffer 524288000

git config --global http.version HTTP/1.1

git clone repo_url --depth 1

git fetch --unshallow

git config --global core.compression 0

echo 1 > /proc/sys/net/netfilter/nf_conntrack_tcp_be_liberal

export GIT_TRACE_PACKET=1
export GIT_TRACE=1
export GIT_CURL_VERBOSE=1

git config --global pack.windowMemory "100m"
git config --global pack.SizeLimit "100m"
git config --global pack.threads "1"
git config --global pack.window "0"

以上指令都是沒效的,浪費了不少時間,最後還得把設定清掉並重開機:

查看設定

$ git config --global -l

移除單一設定

$ git config --global --unset pack.threads

移除群組設定

$ git config --global --remove-section pack

或直接編輯設定檔,這個檔在git 的根目錄上。

$ vi .gitconfig

 

經過幾次嘗試,我發現這個錯誤總是發生在接收大小約為1G的時候出錯,於是我想錯誤的原因會不會是出現在 gitlab 身上而不是我的伺服器本身?

其實這個問題以前也有出現過一次,那時急於下載駝鳥的解決方法就是改用 ssh,只是他很麻煩得上傳公鑰。這次想真正的解決問題。

於是開始搜尋有關 gitlab 1G的限制設定問題,就找到官網有一個表格[5]:

裡面有一個參數 Maximum site size 1 GB ,而且下面還有加註 The maximum size of your Pages site depends on the maximum artifact size, which is part of GitLab CI/CD.

似乎這就是我的目標:要修改這個參數,網路上沒有找到修改的方法,只能看官網的說明去修改這個參數上 Artifacts maximum size (compressed)

調整了全域和專案中的 Artifacts maximum size 都改成30G結果還是一樣,在下載到 1G 時就斷線。

這其間還研究了 GITLAB本身看有沒有隱藏的設定,無果。

經過我多次嘗式,後來我在

Admin Area-> Settings -> CI/CD -> Package file size limits

中找到下面欄位,把他改成約3G大小,再重試

Maximum Terraform Module package file size in bytes

Generic package file size in bytes

<沒有填,但是不確定是不是本來就沒有還是不小心刪了?>

本來想說填個3g看會不在3g的地方停止,沒想到重試竟然就成功了:

remote: Enumerating objects: 89044, done.
remote: Counting objects: 100% (632/632), done.
remote: Compressing objects: 100% (631/631), done.
remote: Total 89044 (delta 3), reused 609 (delta 1), pack-reused 88412
Receiving objects: 100% (89044/89044), 10.83 GiB | 10.65 MiB/s, done.
Resolving deltas: 100% (26302/26302), done.
From http://example/yourname/project
 * branch                HEAD       -> FETCH_HEAD
Updating files: 100% (64660/64660), done.

我的確不能理解為什麼設成3 G竟然能傳超過3G的大小?

可能和上面的Artifacts maximum size 也有關係,這次就懶得做實驗了。

ps:網頁上修改 gitlab 參數不必重啟 gitlab。

 

參考資料

[1] https://blog.csdn.net/yihuajack/article/details/103650588

[2] https://stackoverflow.com/questions/48200429/not-able-to-clone-large-repo-code-on-git

[3] https://stackoverflow.com/questions/26286155/pull-large-repository-more-than-1gb-size-over-http-fail

[4] https://confluence.atlassian.com/bitbucketserverkb/git-clone-fails-fatal-the-remote-end-hung-up-unexpectedly-fatal-early-eof-fatal-index-pack-failed-779171803.html

[5] https://docs.gitlab.com/ee/user/gitlab_com/

 

 

END

你可能感興趣的文章

[GITLAB] 讓git可以用ssh push,解決 Permission denied (publickey).的問題 在使用git push資料的時候發生 Permission denied (publickey).的問題,有沒有解法?

WD硬碟保固查詢及送修 送修壞掉的WD硬碟,這篇是過程記錄

UTF8和unicode的轉換 常聽到的 unicode, utf8, ascii 又是什麼?utf8和unicode之間的關係及如何轉換?

台灣2023(民國112年)節慶國定假日 ics下載 找不到2023年的假日ics檔?沒關係,我自己做一個。

Chrome的遠端桌面(遠桌)使用 Chrome 具有遠端桌面(遠桌),可以輕易的讓你連到或被連到遠端電腦

git 中的 git(git 次模組) 版本控制引擎git 中的 git(git 次模組) / git inside git/ git submodule

隨機好文

[jQuery] 利用load()來達成ajax的寫法 jQuery中利用load()來達成ajax的寫法,也有人稱他是假的ajax,作法就是..

[jQuery] textarea 的取值和給值 HTML 的 TEXTAREA 標籤若要用 jquery 取值,不能使用 .text() 或 .html() ,使用 .

為什麼要重造輪子? 什麼輪子?造什麼輪子?我為什麼要重造輪子?

APACHE的記錄檔格式 LogFormat 語法 在APACHE中有定義一些記錄的語法模版 在 /etc/httpd/conf/httpd.conf 中: LogForm

[PHP] 檢查IP是否在某個網段內 mtachcidr 要檢查IP是否在某個網段內,要寫幾行?10行?5行? 不用,只要2行。以下是我寫的 code /** * matchCI