I have been using intensively the Feeds module. After many imports of data doing test, I sometimes get the following error message: ´SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry taxonomy_term-32591-0-0-und' for key 'PRIMARY'

Can I clean the database in such a way that I will no longer have this error message? Of course, when it happens, the taxonomy terms are not imported. After deleting the Feeds and importing again, it goes perfect, but the problem happens from time to time.

I don't think I have many extra modules which will store taxonomy tid's on them, so maybe the problem is with the core database tables, but I cannot find where there are still rows to be deleted manually to solve the problem.

Because the data are already corrupted, I pretend to manually repair the integrity of database (or with the help of a module) without having to look for a previous backup, which would imply losing hours of work done on other sections (and thus tables of the database).

  • 3
    It looks to me it should be a bugreport, not question here. Module should not left SQL errors unhandled, and if you never tampered with your DB manually, if you were doing things via GUI or using tools like drush, you shouldn't get DB in unstable state anyway - so there are probably two bugs you just found.
    – Mołot
    Commented Oct 8, 2015 at 20:58
  • I have made a fresh import after TRUNCATE of the taxonomies database tables, and all seems perfect. That is my first manual procedure in the tables; I suspect the problem is with other module that handles massive amount of taxonomy data, its behaviour was strange earlier. In any case, my question was if there were other tables besides those with prefix taxonomy where to look for remnants of data (I had deleted with the GUI Admin all nodes which has the taxonomy terms associated) and if I could delete the rows manually. This is also why I said that I had no extra modules related to taxonomy.
    – Cesar
    Commented Oct 9, 2015 at 6:29
  • When you truncated manually, you circumvented all built-in cleaning procedures, and hence you have a mess. Add this to your question because that's pretty important info. And don't do it again.
    – Mołot
    Commented Oct 9, 2015 at 7:29
  • I haven't expressed correctly: I have deleted manually after the problem arised. Before that, the other module was not deleting properly. In any case, there must be some module to check the integrity of data, isn't it? For example, I noticed that url_alias table was filled with taxonomy entries. Surely, following the convention of names and definitions of Drupal, there must exist such a tool which would detect such inconsistence. That is what I would need it. But the corruption to the database was prior to manual intervention, which I have done because it is already corrupted.
    – Cesar
    Commented Oct 9, 2015 at 7:52

1 Answer 1


Finally, I have discovered the problem. I deleted the taxonomy data with the module Taxonomy Manager. When importing the data with Feeds again, it believes that the data remains there, even if they longer no exists. From here, some failed imports can make database corrupted.

To regain integrity, I looked for the problem tid, and checked that it appears in field_data_* with entity_type = 'taxonomy_term' and field_revision_* with the same entity_type. I also appears in url_alias, and didn't find any more instance of tid's with the problems in any more tables. I truncated all these tables.

I also checked that both modules, when deleting taxonomy terms, if the tables are empty, they don't make an additional TRUNCATE, so the new tid's don't start at tid = 1.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.