Avoid database writes on the frontend

If, for whatever reason, the database writes aren't initially successful, this
could run repeatedly on the frontend and crash the site.