Node Access table goes empty I currently have a project where I am inserting mulitple records into Drupal using node_save. Its usually a couple of hundred at a time. For some reason, sometimes the node_access table ends up empty, resulting in the data "appearing" deleted to the users.

Does anyone know what could possible be happening?

I have reviewed the node_save code and notice is does run a call to rebuild the node_access table via node_access_acquire_grants($node). Currently I have no modules implementing node_access hooks.

My one thought was to just call node_access_rebuild() once I've finished inserting. I also run the process a few times every hour.

Side Note: Drupal may not be the right system for the bulk inserts and volume, but that is not the discussion I wish to have on this question.
The only moment where the node access table could be empty is when node_access_write_grants() (or node_access_rebuild()) deletes the content of the table before to repopulate it.
In the case of node_access_write_grants(), the table could become empty only if the table contained the access data for a node; in the case of node_access_rebuild(), the table becomes empty in any cases.

Sometimes the all entry can vanish, as node_access_acquire_grants() adds that entry only if no modules returned access records for the node passed as argument to the function, and node_access_rebuild() adds that entry if no module returned access records.

To notice also that, in the case the $realm passed to node_access_write_grants() doesn't match with the value contained in $grant['realm'] (for all the grants passed to the function), then node_access_write_grants() will delete the access records for the node passed as argument, but it will not save any access records.

// Only perform work when node_access modules are active.
if (count(module_implements('node_grants'))) {
  foreach ($grants as $grant) {
    if ($realm &amp;&amp; $realm != $grant['realm']) {
      continue;
    }
    // Only write grants; denies are implicit.
    if ($grant['grant_view'] || $grant['grant_update'] || $grant['grant_delete']) {
      db_query("INSERT INTO {node_access} (nid, realm, gid, grant_view, grant_update, grant_delete) VALUES (%d, '%s', %d, %d, %d, %d)", $node-&gt;nid, $grant['realm'], $grant['gid'], $grant['grant_view'], $grant['grant_update'], $grant['grant_delete']);
    }
  }
}


The same can happen if a module calls node_access_write_grants() using the default value for $delete, and there aren't modules implementing hook_node_grants().
In these cases, the node access table can become empty if the table contained data only for the node passed as argument to node_access_write_grants().