Closed Bug 528911 Opened 10 years ago Closed 10 years ago

lockFile should catch IOError when open()ing lock file

Categories

(Firefox Build System :: General, defect)

defect
Not set

Tracking

(status1.9.2 beta4-fixed)

RESOLVED FIXED
Tracking Status
status1.9.2 --- beta4-fixed

People

(Reporter: ted, Assigned: Pike)

References

()

Details

Attachments

(1 file)

We hit a build error where JarMaker failed with a Python exception related to handling the lock file:
Traceback (most recent call last):
  File "/builds/slave/mozilla-central-macosx/build/config/JarMaker.py", line 498, in <module>
    main()
  File "/builds/slave/mozilla-central-macosx/build/config/JarMaker.py", line 495, in main
    localedirs=options.l10n_src)
  File "/builds/slave/mozilla-central-macosx/build/config/JarMaker.py", line 286, in makeJars
    jardir=jardir)
  File "/builds/slave/mozilla-central-macosx/build/config/JarMaker.py", line 231, in makeJar
    localedirs)
  File "/builds/slave/mozilla-central-macosx/build/config/JarMaker.py", line 316, in processJarSection
    jf = ZipFile(jarfilepath, 'a', lock = True)
  File "/builds/slave/mozilla-central-macosx/build/config/MozZipFile.py", line 55, in __init__
    self.lockfile = lockFile(file + '.lck')
  File "/builds/slave/mozilla-central-macosx/build/config/utils.py", line 77, in lockFile
    f = open(lockfile, "r")
IOError: [Errno 2] No such file or directory: '../../../dist/bin/chrome/browser.jar.lck'

It sounds like this is just a race condition, where the lock file existed, but was removed before it could be opened (to read the owner PID). lockFile attempts to handle this situation by catching an OSError exception, and checking if it's ENOENT, but an IOError is what's actually raised here:
http://mxr.mozilla.org/mozilla-central/source/config/utils.py#79
The Python docs say IOError is what's supposed to be raised, so this must just be a subtle race bug:
http://docs.python.org/library/functions.html#open
Both OSError and IOError are EnvironmentError, so I just needed to make that more generic. http://docs.python.org/library/exceptions.html#exceptions.EnvironmentError doesn't indicate that that's new.
Assignee: nobody → l10n
Status: NEW → ASSIGNED
Attachment #412678 - Flags: review?(ted.mielczarek)
Attachment #412678 - Flags: review?(ted.mielczarek) → review+
Duplicate of this bug: 529123
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
FWIW, I would be willing to bet we only started seeing these recently because I landed bug 462381 yesterday.
Comment on attachment 412678 [details] [diff] [review]
fix race condition

Requesting approval for 1.9.2

This is a correctness patch for our build infra, I think we should take that independent of whether we take the PARALLEL_DIRS sprinkle or not.
Attachment #412678 - Flags: approval1.9.2?
Comment on attachment 412678 [details] [diff] [review]
fix race condition

I agree. Minimal impact on the actual product, but fixes a real race condition in the build system.
Attachment #412678 - Flags: approval1.9.2? → approval1.9.2+
Product: Core → Firefox Build System
You need to log in before you can comment on or make changes to this bug.