Where is the module registry stored outside the database? As a long time Drupal dev, I should probably know the answer to this question, but I'm stumped by the behavior I'm seeing.

Let's say I have a local and a remote site.  On the remote site a module is uninstalled properly and the module code is removed from the file system (git tracks the deletion, etc).

Then to get my local installation up to date, I completely drop all tables in my database (it's completely empty) and I do a git pull, so the local module files are deleted. I then get the remote database and load it into my local.

In that situation there are no database remnants from my old local install and the file system is updated with the deleted modules.  It should reflect the remote site completely.

However, when I load up the local site I get all the 'XXXX module is missing" and everything breaks.  I run the registry rebuild via drush rr, and it fixes everything.  But then, going forward into the future, I continue to see this broken registry each time I reload the site from the remote database (meaning I have to rr each time).

This strikes me as so odd...because where are those old registry records stored outside the database? Why, if I have a fully clean database, does it recognize old modules as missing?  

And of course...how can I 'clean them up' permenantly?
Common causes:


External cache (Memcache, etc) that is not purged on rebuild
Your SQL import contains cache from prod (I tend to make sure backups make cache tables structure-only).
Your SQL is imported into a DB which contains tables, but does not drop some of them (such as cache). (I personally drop and create the DB before each import).
The module is still enabled/present in the system table (confirm in your SQL that the row in the system table is gone/disabled &amp; uninstalled).
Something else on your site depends on it and is re-enabling it (eg master module, feature dependencies, etc (although dependencies usually block things from being disabled)).
Sometimes worth doing a drush cc drush after importing the SQL. When in doubt, clear caches ;)