What other tables cross index the topic id?
Did you delete those rows as well?
What other tables cross index fields in those other tables?
Did you delete those rows?
rinse - repeat - until all are deleted.
IMHO it is much safer and a lot simpler to “delete” a topic using the UI than to delete it from the database.
AFAIK there is no “on delete cascade” code in Core and deleting fields from tables is not a supported practice, and hence not a Bug.