Skip to content

Instantly share code, notes, and snippets.

@AlainODea
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlainODea/dc841046524cd7833da8 to your computer and use it in GitHub Desktop.
Save AlainODea/dc841046524cd7833da8 to your computer and use it in GitHub Desktop.
Diagnostics for EAGAIN error in GHC Builder on SmartOS

Builder Client encounters errors like:

builder-client: fd:11: hGetLine: resource exhausted (Resource temporarily unavailable)

The string resource exhausted comes from the Show instance for IOErrorType:

The string Resource temporarily unavailable comes from calling strerror on the underlying SmartOS system:

EAGAIN is mapped to ResourceExhausted in the Foreign C Error mapping in base:

The error message as whole is formatted by the Show instance of IOException:

hGetLine calls hGetLineBuffered calls hGetLineBufferedLoop calls maybeFillReadBuffer which considers anything other than EOF an error:

This flaw might be in using hGetLine on a non-blocking Handle at which point the error lies in ghc-builder and not in hGetLine itself.

This appears to be triggered by getLines in Builder.Command in GHC builder:

It is calling hGetLine on the handles returned from runInteractiveProcess which are binary by default:

References:

@AlainODea
Copy link
Author

And now to close the loop as recommended by @rmustacc on #smartos.

This is easily reproducible in a login shell with "C" locale:

[root@ghc-builder-x86-64-smartos ~/builder]# unset LANG
[root@ghc-builder-x86-64-smartos ~/builder]# unset LC_CTYPE
[root@ghc-builder-x86-64-smartos ~/builder]# unset LC_NUMERIC
[root@ghc-builder-x86-64-smartos ~/builder]# unset LC_TIME
[root@ghc-builder-x86-64-smartos ~/builder]# unset LC_COLLATE
[root@ghc-builder-x86-64-smartos ~/builder]# unset LC_MONETARY
[root@ghc-builder-x86-64-smartos ~/builder]# unset LC_MESSAGES
[root@ghc-builder-x86-64-smartos ~/builder]# unset LC_ALL
[root@ghc-builder-x86-64-smartos ~/builder]# locale
LANG=
LC_CTYPE="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_COLLATE="C"
LC_MONETARY="C"
LC_MESSAGES="C"
LC_ALL=
[root@ghc-builder-x86-64-smartos ~/builder]# builder-client --do-build
[2014-05-19 23:14:26] [smartos-x86_64-head] Connecting...
[2014-05-19 23:14:27] [smartos-x86_64-head] Connected.
[2014-05-19 23:14:27] [smartos-x86_64-head] Sending: "PROTO 0.3"
Received: "200 Protocol version OK"
[2014-05-19 23:14:27] [smartos-x86_64-head] Sending: "START SSL"
Received: "200 Welcome to SSL"
[2014-05-19 23:14:28] [smartos-x86_64-head] Sending: "AUTH smartos-x86_64-head nottheactualpassword"
Received: "200 authenticated"
[2014-05-19 23:14:28] [smartos-x86_64-head] Sending: "BUILD INSTRUCTIONS"
Received: "202 What sort?"
Received: "201 Instructions follow"
Received: "200 That's it"
Running "git clone"
Running "create mk/build.mk"
Running "get subrepos"
Running "repo versions"
Running "touching clean-check files"
Running "setting version date"
Running "booting"
builder-client: fd:12: hGetLine: resource exhausted (Resource temporarily unavailable)
[2014-05-19 23:22:09] [smartos-x86_64-head] Sending: "UPLOAD 75 1"
Received: "202 Send name"
Received: "202 Send subdir"
Received: "202 Send program"
Received: "202 Send args"
Received: "202 Send mailOutput"
Received: "202 Send start time"
Received: "202 Send end time"
Received: "202 Send exit code"
Received: "202 Send output"
Received: "202 Send fileUploaded"
Received: "200 Got it, thanks!"
[2014-05-19 23:22:13] [smartos-x86_64-head] Sending: "UPLOAD 75 2"
Received: "202 Send name"
Received: "202 Send subdir"
Received: "202 Send program"
Received: "202 Send args"
Received: "202 Send mailOutput"
Received: "202 Send start time"
Received: "202 Send end time"
Received: "202 Send exit code"
Received: "202 Send output"
Received: "202 Send fileUploaded"
Received: "200 Got it, thanks!"
[2014-05-19 23:22:17] [smartos-x86_64-head] Sending: "UPLOAD 75 3"
Received: "202 Send name"
Received: "202 Send subdir"
Received: "202 Send program"
Received: "202 Send args"
Received: "202 Send mailOutput"
Received: "202 Send start time"
Received: "202 Send end time"
Received: "202 Send exit code"
Received: "202 Send output"
Received: "202 Send fileUploaded"
Received: "200 Got it, thanks!"
[2014-05-19 23:22:20] [smartos-x86_64-head] Sending: "UPLOAD 75 4"
Received: "202 Send name"
Received: "202 Send subdir"
Received: "202 Send program"
Received: "202 Send args"
Received: "202 Send mailOutput"
Received: "202 Send start time"
Received: "202 Send end time"
Received: "202 Send exit code"
Received: "202 Send output"
Received: "202 Send fileUploaded"
Received: "200 Got it, thanks!"
[2014-05-19 23:22:24] [smartos-x86_64-head] Sending: "UPLOAD 75 5"
Received: "202 Send name"
Received: "202 Send subdir"
Received: "202 Send program"
Received: "202 Send args"
Received: "202 Send mailOutput"
Received: "202 Send start time"
Received: "202 Send end time"
Received: "202 Send exit code"
Received: "202 Send output"
Received: "202 Send fileUploaded"
Received: "200 Got it, thanks!"
[2014-05-19 23:22:28] [smartos-x86_64-head] Sending: "UPLOAD 75 6"
Received: "202 Send name"
Received: "202 Send subdir"
Received: "202 Send program"
Received: "202 Send args"
Received: "202 Send mailOutput"
Received: "202 Send start time"
Received: "202 Send end time"
Received: "202 Send exit code"
Received: "202 Send output"
Received: "202 Send fileUploaded"
Received: "200 Got it, thanks!"
[2014-05-19 23:22:32] [smartos-x86_64-head] Sending: "UPLOAD 75 7"
Received: "202 Send name"
Received: "202 Send subdir"
Received: "202 Send program"
Received: "202 Send args"
Received: "202 Send mailOutput"
Received: "202 Send start time"
Received: "202 Send end time"
Received: "202 Send exit code"
Received: "202 Send output"
Received: "202 Send fileUploaded"
Received: "200 Got it, thanks!"
[2014-05-19 23:22:36] [smartos-x86_64-head] Sending: "RESULT 75"
Received: "202 Send instructions"
Received: "202 Send result"
Received: "200 Got it, thanks!"
[2014-05-19 23:22:36] [smartos-x86_64-head] Sending: "RESET TIME"
Received: "200 Done"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment