Does Drupal cache db_query results for multiple users?
You need to put in an else {...} after using lock_acquire(); or have it return right after calling  lock_wait().

Also, db_query is not cached in any way