757: 1153, "Got a packet bigger than 'max_allowed_packet' bytes"

ajaykr******@gmai***** (Google Code) (Is this you? Claim this profile.)
Feb. 10, 2009
What's the URL of the page containing the problem?
When i update diff

What steps will reproduce the problem?
1.
2.
3.

What is the expected output? What do you see instead?


What operating system are you using? What browser?


Please provide any additional information below.
david
#1 david
Where did you see this error? If it was a python error, can you get a traceback?
  • +NeedInfo
david
#2 david
Closing out, because the needed information was not provided. If you can provide this
info, please add a comment and we'll reopen the bug.
  • -NeedInfo
    +Incomplete
#3 kelvin.*******@gmai***** (Google Code) (Is this you? Claim this profile.)
I was able to reproduce this issue by submitting a diff that was larger than mysql's max_allowed_packet size.

from post-review:

>>> Review request created
>>> Uploading diff, size: 1593200
>>> HTTP POSTing to http://reviews/api/json/reviewrequests/13/diff/new/: {}
Error uploading diff: One or more fields had errors (105)
>>> {u'fields': {u'path': [u'(1153, "Got a packet bigger than \'max_allowed_packet\' bytes")']}, u'stat': u'fail', 
u'err': {u'msg': u'One or more fields had errors', u'code': 105}}
Your review request still exists, but the diff is not attached.


mysql> show variables like "max_allowed_packet";
+--------------------+---------+
| Variable_name      | Value   |
+--------------------+---------+
| max_allowed_packet | 1048576 | 
+--------------------+---------+
1 row in set (0.00 sec)

Note the diff size 1593200 vs the max_allowed_packet default size 1048576


http://dev.mysql.com/doc/refman/5.1/en/packet-too-large.html suggests that it needs to be a co-
ordinated change on both the client- and server-side.


#4 eva***@gmai***** (Google Code) (Is this you? Claim this profile.)
Diffs that huge are unreviewable anyway, and probably binary, so there's not really a
good reason to store them in the DB.  Here's a quick patch to skip over them.
  • +
    --- a/src/ReviewBoard/reviewboard/reviewboard/diffviewer/parser.py
    +++ b/src/ReviewBoard/reviewboard/reviewboard/diffviewer/parser.py
    @@ -42,6 +42,7 @@ class DiffParser(object):
             self.files = []
             file = None
             i = 0
    +        fileData = "" # accumulates all diff lines for a file
     
             # Go through each line in the diff, looking for diff headers.
             while i < len(self.lines):
    @@ -49,19 +50,31 @@ class DiffParser(object):
     
                 if new_file:
                     # This line is the start of a new file diff.
    +                if file:
    +                    file.data += self._check_diff_size(file, fileData)
    +                fileData = ""
                     file = new_file
                     self.files.append(file)
                     i = next_linenum
                 else:
                     if file:
    -                    file.data += self.lines[i] + "\n"
    -
    +                    fileData += self.lines[i] + "\n"
                     i += 1
     
    +        if file:
    +            fil