Is site safe after a failed module installation? I was working on a site this morning, and I enabled a whole bunch of modules at the same time.  One of the modules threw a PDO exception during the process.

What state is the site in at this point?  Assuming the site still loads after the error, is it safe to use, or should I restore from a backup?

For the sake of this question, I am not concerned about the actual error or the module that threw the error (I would report this in the issue queue).  I am concerned about the general state of the site, and what may have happened to the installations of the other modules.

To make this more concrete, let's say I tried to enable ModuleA, ModuleB, ModuleC, and ModuleD.  After I clicked SUBMIT on the module page, ModuleC threw an uncaught PDO Exception and I didn't get the normal module enabled message.  Now, lets say that I can live without ModuleC on the site.  What can be said about the state of hpw the installation went for ModuleA, ModuleB, and ModuleD, and also dor Drupal in general?
Generally, it isn't. It may be, but it depends what's in module's hook_install. 

First, most modules provide schema. The code of drupal_install_schema in 7 is currently:

function drupal_install_schema($module) {
  $schema = drupal_get_schema_unprocessed($module);
  _drupal_schema_initialize($schema, $module, FALSE);

  foreach ($schema as $name =&gt; $table) {
    db_create_table($name, $table);
  }
}


As you can see, no call to db_translation, and each table is created one at a time. Now, if module only provides own schema, you are left with some garbage in database, but it's a well isolated garbage. But if it implements hook_schema_alter it's pretty possible you are left with some tables already altered, bu no code to handle these alterations. Now, in theory installing schema should never fail with PDO error, but due to RDBMS configuration for example, it may happen.

Second problem is that module's author can write pretty much anything in it's install code, and you are not guaranteed it will get rolled back at failed install. If he decides his module needs to change variables provided by core or other modules (for example to allow apparent conditional content, like with translated variables), or if it redefines some fields to provide additional functionality, you may end up with some of your data converted to module's format, and no longer accessible without it, or without running code meant to uninstall it.



Note: Situations above from experience. Even if I miss some theoretical part that should make them impossible to happen, they both did happened to me in real life. With -dev versions, but module version depends solely on it's author, so there is no guarantee that it will not happen in stable versions some day, too.