Cscott has uploaded a new change for review. https://gerrit.wikimedia.org/r/176815
Change subject: Don't halt gc due to readdir after clean; more verbose error
reporting.
......................................................................
Don't halt gc due to readdir after clean; more verbose error reporting.
If there is a race with another gc process and the directory is removed
after it is cleaned, just skip the directory and go on (instead of
throwing an exception and halting the gc process).
Include a msg field with the error list to record additional information
about the cause of any particular error seen during directory clean up.
Change-Id: Id7c20b30be896afc93db512fb147b76caa3a875e
---
M lib/threads/gc.js
1 file changed, 26 insertions(+), 8 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Collection/OfflineContentGenerator
refs/changes/15/176815/1
diff --git a/lib/threads/gc.js b/lib/threads/gc.js
index 4b51b1a..1d63a14 100644
--- a/lib/threads/gc.js
+++ b/lib/threads/gc.js
@@ -201,9 +201,12 @@
// ensure that we don't blow up our memory usage by
trying to
// do a bread-first traversal of the directory tree.
var dfsclean = Promise.guard( 1, clean );
- return readdir( dir ).catch( function( error ) {
+ return readdir( dir ).catch( function( e ) {
// directory already removed?
- errors.push( dir );
+ errors.push({
+ msg: "readdir: " + e,
+ path: dir
+ });
return [];
}).map( function( file ) {
var fullpath = path.join( dir, file );
@@ -224,22 +227,37 @@
if
(files.length === 0) {
return
rmdir( fullpath ).then(function(){
count += 1;
- },
function(error) {
-
errors.push(fullpath);
+ },
function( e ) {
+
errors.push({
+
msg: "rmdir: " + e,
+
path: fullpath
+
});
});
}
+ }, function( e ) {
+ /* it went away
after we cleaned it? */
+ errors.push({
+ msg:
"readdir after clean: " + e,
+ path:
fullpath
+ });
});
});
} else {
return unlink( fullpath
).then(function() {
count += 1;
- }, function(error) {
- errors.push( fullpath );
+ }, function( e ) {
+ errors.push({
+ msg: "unlink: "
+ e,
+ path: fullpath
+ });
});
}
- }, function(error) {
+ }, function( e ) {
// error during stat -- file already
gone?
- errors.push( fullpath );
+ errors.push({
+ msg: "stat: " + e,
+ path: fullpath
+ });
});
});
};
--
To view, visit https://gerrit.wikimedia.org/r/176815
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id7c20b30be896afc93db512fb147b76caa3a875e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Collection/OfflineContentGenerator
Gerrit-Branch: master
Gerrit-Owner: Cscott <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
