Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 2247 by degrande...@gmail.com: Deadlock when calling 'patch' with a very large diff
http://code.google.com/p/reviewboard/issues/detail?id=2247

* NOTE: Do not post confidential information in this bug report. *
*       If you need immediate support, please contact            *
*       reviewbo...@googlegroups.com                             *

What version are you running?

1.6RC2

We often have a high memory consumption on our reviewboard server, and when it happens, there are some 'patch' processes blocked.

I looked at how you launch the 'patch' utility, and I think that there is a potential pb, due to the use of Popen.wait() with pipes. According to the documentation (http://docs.python.org/library/subprocess.html#popen-objects), there is a potential deadlock if the date sent to the pipe is larger than the pipe buffer size (we have some very huge diffs).

Here is a small python code to reproduce it:

--------------------------------------
import sys, subprocess

def main():

  data = ""
  for i in range(100000):
    data += "%d\n" % i

p = subprocess.Popen(['cat'], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
  p.stdin.write(data)
  p.stdin.close()
  output = p.stdout.read()
  failure = p.wait()

  if failure:
    print("error")
    sys.exit(1)

  sys.stdout.write(output)

if __name__ == '__main__': main()
-----------------------------------------------------------

As long as 'data' is small enough (i.e. with a small maximum value of 'i'), everything works well. But with 'i' ranging from 0 to 100000, p.wait() blocks.

The documentation recommends to use Popen.communicate()

--
You received this message because you are subscribed to the Google Groups 
"reviewboard-issues" group.
To post to this group, send email to reviewboard-issues@googlegroups.com.
To unsubscribe from this group, send email to 
reviewboard-issues+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/reviewboard-issues?hl=en.

Reply via email to