[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
19/118: Report daemon OOM better
From: |
Ludovic Courtès |
Subject: |
19/118: Report daemon OOM better |
Date: |
Tue, 19 May 2015 14:45:18 +0000 |
civodul pushed a commit to branch nix
in repository guix.
commit b1beed97a0670befbfd5e105a81132e87e58ac37
Author: Eelco Dolstra <address@hidden>
Date: Tue Jun 10 13:45:50 2014 +0200
Report daemon OOM better
When copying a large path causes the daemon to run out of memory, you
now get:
error: Nix daemon out of memory
instead of:
error: writing to file: Broken pipe
---
src/libstore/remote-store.cc | 22 +++++++++++++++++-----
src/nix-daemon/nix-daemon.cc | 6 ++----
2 files changed, 19 insertions(+), 9 deletions(-)
diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc
index 177b8e7..3b021bb 100644
--- a/src/libstore/remote-store.cc
+++ b/src/libstore/remote-store.cc
@@ -402,11 +402,23 @@ Path RemoteStore::addToStore(const Path & _srcPath,
writeInt((hashAlgo == htSHA256 && recursive) ? 0 : 1, to);
writeInt(recursive ? 1 : 0, to);
writeString(printHashType(hashAlgo), to);
- to.written = 0;
- to.warn = true;
- dumpPath(srcPath, to, filter);
- to.warn = false;
- processStderr();
+
+ try {
+ to.written = 0;
+ to.warn = true;
+ dumpPath(srcPath, to, filter);
+ to.warn = false;
+ processStderr();
+ } catch (SysError & e) {
+ /* Daemon closed while we were sending the path. Probably OOM
+ or I/O error. */
+ if (e.errNo == EPIPE)
+ try {
+ processStderr();
+ } catch (EndOfFile & e) { }
+ throw;
+ }
+
return readStorePath(from);
}
diff --git a/src/nix-daemon/nix-daemon.cc b/src/nix-daemon/nix-daemon.cc
index 8814fe3..0464ac9 100644
--- a/src/nix-daemon/nix-daemon.cc
+++ b/src/nix-daemon/nix-daemon.cc
@@ -735,12 +735,10 @@ static void processConnection(bool trusted)
during addTextToStore() / importPath(). If that
happens, just send the error message and exit. */
bool errorAllowed = canSendStderr;
- if (!errorAllowed) printMsg(lvlError, format("error processing
client input: %1%") % e.msg());
stopWork(false, e.msg(), GET_PROTOCOL_MINOR(clientVersion) >= 8 ?
e.status : 0);
- if (!errorAllowed) break;
+ if (!errorAllowed) throw;
} catch (std::bad_alloc & e) {
- if (canSendStderr)
- stopWork(false, "Nix daemon out of memory",
GET_PROTOCOL_MINOR(clientVersion) >= 8 ? 1 : 0);
+ stopWork(false, "Nix daemon out of memory",
GET_PROTOCOL_MINOR(clientVersion) >= 8 ? 1 : 0);
throw;
}
- 02/118: nix-store -l: Fetch build logs from the Internet, (continued)
- 02/118: nix-store -l: Fetch build logs from the Internet, Ludovic Courtès, 2015/05/19
- 03/118: Disable parallel.sh test, Ludovic Courtès, 2015/05/19
- 07/118: Add constant ‘nixPath’, Ludovic Courtès, 2015/05/19
- 14/118: Use std::unordered_set, Ludovic Courtès, 2015/05/19
- 13/118: nix-build: --add-root also takes 1 parameter, Ludovic Courtès, 2015/05/19
- 16/118: Fix test, Ludovic Courtès, 2015/05/19
- 15/118: Sort nixPath attributes, Ludovic Courtès, 2015/05/19
- 10/118: Remove ExprBuiltin, Ludovic Courtès, 2015/05/19
- 09/118: Make the Nix search path declarative, Ludovic Courtès, 2015/05/19
- 04/118: Ugly hack to allow --argstr values starting with a dash, Ludovic Courtès, 2015/05/19
- 19/118: Report daemon OOM better,
Ludovic Courtès <=
- 06/118: Add primop ‘scopedImport’, Ludovic Courtès, 2015/05/19
- 21/118: Add autoloads, make code more concise & idiomatic, Ludovic Courtès, 2015/05/19
- 25/118: Fix bogus warnings about dumping large paths, Ludovic Courtès, 2015/05/19
- 20/118: == operator: Ignore string context, Ludovic Courtès, 2015/05/19
- 17/118: nix-env -qa --json: Generate valid JSON even if there are invalid meta attrs, Ludovic Courtès, 2015/05/19
- 23/118: findFile: Realise the context of the path attributes, Ludovic Courtès, 2015/05/19
- 11/118: Rephrase @ operator description, Ludovic Courtès, 2015/05/19
- 29/118: Merge branch 'shlevy-import-native', Ludovic Courtès, 2015/05/19
- 12/118: dev-shell is a bash script, not sh, Ludovic Courtès, 2015/05/19
- 22/118: Share code between scopedImport and import, Ludovic Courtès, 2015/05/19