FS#44430 - [foomatic-db-engine] Adding new printer stalls, high CPU load foomatic list

Attached to Project: Arch Linux
Opened by Bastien Traverse (Neitsab) - Wednesday, 01 April 2015, 15:55 GMT
Last edited by Andreas Radke (AndyRTR) - Thursday, 28 July 2016, 19:59 GMT
Task Type Bug Report
Category Upstream Bugs
Status Closed
Assigned To Andreas Radke (AndyRTR)
Architecture All
Severity Medium
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 3
Private No

Details

Description:

When trying to add a new wifi printer (Epson_Stylus_SX420W, authenticated with the AP) through CUPS web interface:
- the printer is immediately detected;
- it is selectable under two entries :
* one is "EPSON3B2202 (Epson Stylus SX420W) (EPSON Epson Stylus SX420W)" and matches the dnssd protocol (dnssd://EPSON3B2202%20(Epson%20Stylus%20SX420W)._printer._tcp.local/), as I'd later discover;
* the other is "EPSON Epson Stylus SX420W (Epson Stylus SX420W)" and matches the lpd PASSTHRU version (lpd://192.168.1.200:515/PASSTHRU).
- however, when I select either one and click on "Continue", the page just gets stuck loading while the process /usr/bin/perl /usr/lib/cups/driver/foomatic list hogs one CPU to the max. I then have to restart the process after waiting circa 1 minute and go through the whole process again.

After retrying a few times and re-reading the CUPS wiki page I uninstalled foomatic-db{,-engine}, rebooted and tried again to add my printer.
This time I could go past the "Continue" button immediately and see the protocol information for each entry, and then carry on with the installation by manually selecting the printer maker and model.

If I'd select the dnssd entry it would fail to print because it set the location to localhost, but with the lpd entry I can finally print remotely without any troubles.

I used to be affected by the similar cupsd bug  FS#42666  but now cupsd doesn't get a high CPU usage, only foomatic does.
I couldn't find a similar bug report on the upstream bugtracker (https://bugs.linuxfoundation.org/buglist.cgi?query_format=specific&order=relevance+desc&bug_status=__all__&product=OpenPrinting&content=).

Additional info:
* package version(s): foomatic-db-engine 3:20150308-1, {lib,}cups 2.0.2-3, gutenprint 5.2.10-1
* config and/or log files etc.
Unmodified

Steps to reproduce:
- Install cups, foomatic-db{,engine} and gutenprint
- Log in CUPS web interface and try to add a new (wifi) printer
- See whether /usr/bin/perl /usr/lib/cups/driver/foomatic list is taking a whole CPU.
This task depends upon

Closed by  Andreas Radke (AndyRTR)
Thursday, 28 July 2016, 19:59 GMT
Reason for closing:  Fixed
Comment by Andreas Radke (AndyRTR) - Thursday, 02 April 2015, 05:06 GMT
Please check your cups logfiles using debug mode. It may help to recompile cups 1.7.x to check if the load is caused by the cups update or foomatic. Then go further with debugging and get in contact with upstream.
Comment by Andreas Radke (AndyRTR) - Saturday, 18 April 2015, 07:59 GMT
Have you reported this upstream to foomatic cups-filters devs? But maybe it's even another bug in cups itself.
Comment by Chris Severance (severach) - Wednesday, 22 April 2015, 06:18 GMT
IBM ThinkServer TS140, 3.19.3-3-ARCH x86_64, E3-1225, 32GB RAM, SAS drives
cups 2.0.2-4, gutenprint 5.2.10-1, foomatic-db 3:20150308-1, foomatic-db-engine 3:20150308-1

This seems to be related to my problem and the problem isn't with gutenprint or foomatic. If I install gutenprint or foomatic but not both, I can view the printer list after clicking [Continue] on the "Name:Description:Location:" screen. If I install both I get an error in about a minute:

Add Printer a Error
Unable to get list of printer drivers:
Success

I think the web server is timing out. Maybe a little less beefy computer doesn't display a message at all. Whether there's a timeout fix or not a 30+ second delay to add a printer is too long. Someone needs to rethink how lots of printers can be accessed quickly. Having foomatic, gutenprint, and hplip on the same system just doesn't work. foomatic is the largest package so is the biggest contributor to the problem. I have hplip+gutenprint and I can see the printer list.

Comment by Andreas Radke (AndyRTR) - Wednesday, 22 April 2015, 18:16 GMT
Please raise your issue on the cups mailing list. Let's see what upstream devs say.
Comment by Olivier (olive) - Tuesday, 03 November 2015, 08:54 GMT
I think this bug in the same as https://bugs.archlinux.org/task/43708. This bug is still present. cups executes "/usr/lib/cups/driver/foomatic list" to get the list of driver and this process hang; hence cups times out with an error message. We can execute this command by hand and see that it hangs (or take too much time to complete). It happens when I have foomatic-db-3:20150904-1, foomatic-db-engine-3:20150904-1 and gutenprint-5.2.10-1 installed but this command works correctly when gutenprint is uninstalled (although it still take a few seconds to complete on a core i3 computer). I have check in Ubuntu computer and there "/usr/lib/cups/driver/foomatic list" never hang but they seems to install less files in the above mentioned packages than archlinux.
Comment by Andreas Radke (AndyRTR) - Monday, 09 November 2015, 14:06 GMT
Can you check if there's some broken file also shipped in the gutenprint package? Do you get something useful in cups log?
Comment by Olivier (olive) - Monday, 09 November 2015, 18:54 GMT
I have made some debugging and the culprit is really
/usr/lib/cups/driver/foomatic list
that hangs. It is possible to test this command directly from the command line leaving out cups. I have done some debugging but with no definite answer. I have a simple python script that parse the output of strace (available here http://pastebin.com/DD9TKZNW ; to use it do: "strace /usr/lib/cups/driver/foomatic list |& python2 -u ./parse_strace" ) to list the file that the program open. I see that it hangs with the following file: rastertokmXXXXdl.xml. But it does not seem to be always the same file and moreover this file does not make part of gutenprint. The command "/usr/lib/cups/driver/foomatic list" does not hang in Ubuntu and give the expected list of drivers. I have only seen that Ubuntu ships less files than arch in (the equivalent of packages) foomatic-db and gutenprint but I am unable to find the real culprit.
Comment by Chris Severance (severach) - Tuesday, 10 November 2015, 00:38 GMT
There's no reason to use strace. Use the source, Luke!

You can fix the problem by removing the following files.

# gutenprint-ijs-simplified.5.2.xml |1504797
# gutenprint-ijs.5.2.xml |3046350

sudo rm -f /usr/share/foomatic/db/source/driver/{gutenprint-ijs-simplified.5.2.xml,gutenprint-ijs.5.2.xml}

It isn't locking up and it isn't stopping on any random printer. Due to the large file size, processing slows to a crawl when one of the above two files are hit. It will complete if you're willing to wait forever.

Due to the way hashes work in Perl, the printers are processed in slightly random order which is why you see random printers in the strace list.

#/usr/lib/perl5/vendor_perl/Foomatic/filters/xml/xmlParse.pm is owned by foomatic-db-engine 3:20151108-1

The problem is that xmlParse.pm is not coded well enough to handle XML files this large in a reasonable amount of time. On the way to pinpointing the problem I saw several "Shlemiel the painter's algorithms" which is likely to be the problem.

http://www.joelonsoftware.com/articles/fog0000000319.html

Conclusion: gutenprint is supplying some very large XML files which foomatic is unable to process within the time allowed by CUPS.
Comment by Olivier (olive) - Tuesday, 10 November 2015, 08:06 GMT
I can confirm that the solution of severach fix the "foomatic list" problem and we get the list of printer. Have you an idea of what you loose exactly removing this file?

But Now, we can see some hang when we actually choose a ppd file because this ppd file must be generated. I can see a "hang" with /usr/lib/cups/driver/foomatic cat foomatic:Brother-HL-760-hpijs-pcl5e.ppd (when we choose the HL-760-hpijs-pcl5e.ppd file). This is less serious than previously because it does complete if we launch it by hand in about ~35 sec (on my Intel(R) Core(TM) i3-3240 CPU processor). Probably cups time out after 30s. @severach Do you have an idea how to increase the cups timeout?
Comment by Andreas Radke (AndyRTR) - Tuesday, 10 November 2015, 11:38 GMT
Maybe this bug is caused by not running the /usr/bin/cups-genppdupdate at all or not properly.

I see Fedora and Debian/Ubuntu doing weird special update calls. Not sure if this really needed.
Comment by Andreas Radke (AndyRTR) - Saturday, 16 April 2016, 08:33 GMT
I've splitted foomatic-db and foomatic-db-ppds 3:20160416-1. You can give it a try from the testing repo.

I've also applied a fix I've found in the Fedora spec:

# For gutenprint printers, use gutenprint-ijs-simplified.5.2.
perl -pi -e 's,>gutenprint<,>gutenprint-ijs-simplified.5.2<,' printer/*.xml

This looks related though Till at Debian doesn't seem to use it.

Our Gutenprint pkg currently ships this and now we should properly match it:
/usr/share/foomatic/db/source/driver/gutenprint-ijs-simplified.5.2.xml
/usr/share/foomatic/db/source/driver/gutenprint-ijs.5.2.xml
Comment by Andreas Radke (AndyRTR) - Thursday, 23 June 2016, 18:33 GMT
Status? Is this still an issue for you?
Comment by Olivier (olive) - Thursday, 23 June 2016, 19:07 GMT
It seems that the issue is fixed. That hangs not any longer. Note that I still see a delay of a few seconds (about 3s); which is acceptable. It is unlikely to timeout even on slower machine. Please test yourself. Just install all the foomatic* packages and try to add a printer with the web interface. Also running /usr/lib/cups/driver/foomatic list by hand takes only a few seconds. Maybe others can confirm to be sure.
Comment by Andreas Radke (AndyRTR) - Thursday, 28 July 2016, 19:59 GMT
I've installed all the foomatic+gutenprint+hplip packages from our repos and run "/usr/lib/cups/driver/foomatic list". Output is given after ~3sec. here on a low power Celeron 3150 cpu.

Confirmed - this is fixed now.

Loading...