Wait for cluster safe state before running query. Fixes #3219