From: Shawn Pearce <spearce@spearce.org>
To: Christian Halstrick <christian.halstrick@gmail.com>
Cc: Git <git@vger.kernel.org>, Shawn Pearce <sop@google.com>
Subject: Re: git pack protocol question: sideband responses in case of errors?
Date: Wed, 13 May 2015 08:45:43 -0700 [thread overview]
Message-ID: <CAJo=hJtcM-kV+L_yUX43UPe2Z-4LnaXTBpmFaWaFReG-Jbsisw@mail.gmail.com> (raw)
In-Reply-To: <CAENte7j9De5Bqu2jDcmXQAxZheSGo+EntzsYUaen0N7cnuiCDQ@mail.gmail.com>
On Wed, May 13, 2015 at 2:03 AM, Christian Halstrick
<christian.halstrick@gmail.com> wrote:
> since a long time I am hitting very seldom errors when pushing with a
> jgit client leading to "invalid channel 101" errors on client side. I
> was always wondering why it was always the channel "101". Now I found
> out with wireshark and it leads me to a question regarding the git
> pack protocol [1] and the sideband capability [2] which I couldn't
> answer from the technical docs.
>
> This is what happened: A client wants to push over http to a git
> server. In the beginning they negotiated to use side-band-64k and
> report-status capabilities. Everything works fine, Packfile data
> transmission starts and sideband communication is ok. Now the server
> hits a severe problem persisting the packfile and wants to stop the
> transport. The git server hit's quotas on the filesystem usage and is
> not allowed to persist that big file. My git server (I use a modified
> gerrit server) intends to send back a packet line "0013error: ...".
> But the client when reading that respond still thinks we should use
> sideband communication and interpretes the "e" from "error" as
> channel. The ascii code of "e" is the solution why it was always
> "invalid channel 101"
>
> Here is my question:
> - When exactly should sideband communication during a http based push
> start and when should it end?
If the client asked side-band-64k and report-status capabilities the
server must use side-band to respond to the client. Its (obviously)
assuming this.
The bug here is JGit's ReceivePack/BaseReceivePack code not setting up
the side-band-64k early enough for this failure report to be wrapped
in it.
> Especially in case of an error on the
> server side. Is the server allowed to switch to non-sideband
> communication under special conditions?
No. The protocol has negotiated to use side-band-64k. That is what the
client expects to see.
In side-band-64k channel 2 is the "error" channel. Send a single
packet on channel 2 carrying a single short text message and the
entire stream is aborted at the client side after receiving this
message. This is maybe what JGit should do in this case.
> E.g. when the server responds
> not with 200OK but with 413 (entity too large).
No, you cannot use 413.
> - Is responding with status code 200 mandatory when talking git pack
> protocol? Am I allowed as git server to respond with status code 413
> and fill the body of the response with the status report?
This was hashed out a long time ago. For the purposes of Git the HTTP
200 status code means the HTTP system successfully transported opaque
data for Git, e.g. its like having no socket error from a socket
routine.
Any other HTTP status like 413 means the HTTP transport is busted. Its
like getting EHOSTUNREACH or some other such errno from a socket
function.
I realize there are other interpretations for how applications should
use HTTP status codes, and REST APIs often use them, but Git does not
take that approach.
FWIW I am glad you found this. I have been chasing this bug for years
but couldn't really pin it down to anything. If its the "pack won't
fit on local disk due to disk full" condition that narrows down the
offending section of JGit considerably.
> [1] https://raw.githubusercontent.com/git/git/master/Documentation/technical/pack-protocol.txt
> [2] https://raw.githubusercontent.com/git/git/master/Documentation/technical/protocol-capabilities.txt
prev parent reply other threads:[~2015-05-13 15:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-13 9:03 git pack protocol question: sideband responses in case of errors? Christian Halstrick
2015-05-13 15:45 ` Shawn Pearce [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAJo=hJtcM-kV+L_yUX43UPe2Z-4LnaXTBpmFaWaFReG-Jbsisw@mail.gmail.com' \
--to=spearce@spearce.org \
--cc=christian.halstrick@gmail.com \
--cc=git@vger.kernel.org \
--cc=sop@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).