Problem is that preview render database is being used, but the new datablock function still uses G.main, and the mesh was being added to one database but (attempted to be) removed from another. The proper fix would get rid of the globals here, will look into that later.