From 7eb4b92d309a2118881f78893271bc1c8e5d57b4 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Fri, 21 Sep 2018 14:09:57 +0100 Subject: [PATCH 1/2] cache_store: handle missing process. If we try to kill the process but it's already dead just ignore it. --- Library/Homebrew/cache_store.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/cache_store.rb b/Library/Homebrew/cache_store.rb index ff5ca0ad33..20cd304a7c 100644 --- a/Library/Homebrew/cache_store.rb +++ b/Library/Homebrew/cache_store.rb @@ -89,7 +89,12 @@ class CacheStoreDatabase end rescue ErrorDuringExecution, Timeout::Error odebug "Failed to read #{dbm_file_path}!" - Process.kill(:KILL, dbm_test_read_cmd.pid) + begin + Process.kill(:KILL, dbm_test_read_cmd.pid) + rescue Errno::ESRCH + # Process has already terminated. + nil + end false end cache_path.delete unless dbm_test_read_success From 752714b71ceeb473bdbdb008e645c645cb428d96 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Fri, 21 Sep 2018 14:14:51 +0100 Subject: [PATCH 2/2] cache_store: add dbm_test_read analytics. --- Library/Homebrew/cache_store.rb | 1 + docs/Analytics.md | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/cache_store.rb b/Library/Homebrew/cache_store.rb index 20cd304a7c..c4eaca6072 100644 --- a/Library/Homebrew/cache_store.rb +++ b/Library/Homebrew/cache_store.rb @@ -97,6 +97,7 @@ class CacheStoreDatabase end false end + Utils::Analytics.report_event("dbm_test_read", dbm_test_read_success.to_s) cache_path.delete unless dbm_test_read_success end DBM.open(dbm_file_path, DATABASE_MODE, DBM::WRCREAT) diff --git a/docs/Analytics.md b/docs/Analytics.md index 0c54261f44..b0a149153c 100644 --- a/docs/Analytics.md +++ b/docs/Analytics.md @@ -28,7 +28,8 @@ Homebrew's analytics records the following different events: - an `event` hit type with the `install` event category and the Homebrew formula from a non-private GitHub tap you install plus any used options, e.g. `wget --with-pcre` as the action and an event label e.g. `macOS 10.12, non-/usr/local, CI` to indicate the OS version, non-standard installation location and invocation as part of CI. This allows us to identify the formulae that need fixing and where more easily. - an `event` hit type with the `install_on_request` event category and the Homebrew formula from a non-private GitHub tap you have requested to install (e.g. explicitly named it with a `brew install`) plus options and an event label as above. This allows us to differentiate the formulae that users intend to install from those pulled in as dependencies. - an `event` hit type with the `cask_install` event category and the Homebrew cask from a non-private GitHub tap you install as the action and an event label as above. This allows us to identify the casks that need fixing and where more easily. -- an `event` hit type with the `BuildError` event category and the Homebrew formula that failed to install, e.g. `wget` as the action and an event label e.g. `macOS 10.12` +- an `event` hit type with the `BuildError` event category and the Homebrew formula that failed to install, e.g. `wget` as the action and an event label e.g. `macOS 10.12`. +- an `event` hit type with the `dbm_test_read` event category and `true` or `false` as the action (depending on if a corrupt DBM database was detected) and an event label e.g. `macOS 10.12`. You can also view all the information that is sent by Homebrew's analytics by setting `HOMEBREW_ANALYTICS_DEBUG=1` in your environment. Please note this will also stop any analytics from being sent.