1
votes

I have a big issue today on my website using Drupal 7.22.

This issue appear on new node creation from an admin.

PDOException : SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '308' for key 'PRIMARY': INSERT INTO {node} (nid, vid, type, language, title, uid, status, created, changed, comment, promote, sticky, tnid, translate) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9, :db_insert_placeholder_10, :db_insert_placeholder_11, :db_insert_placeholder_12, :db_insert_placeholder_13); Array ( [:db_insert_placeholder_0] => 308 [:db_insert_placeholder_1] => 308 [:db_insert_placeholder_2] => evenements [:db_insert_placeholder_3] => fr [:db_insert_placeholder_4] => TEST [:db_insert_placeholder_5] => 1 [:db_insert_placeholder_6] => 0 [:db_insert_placeholder_7] => 1381931095 [:db_insert_placeholder_8] => 1381931095 [:db_insert_placeholder_9] => 1 [:db_insert_placeholder_10] => 0 [:db_insert_placeholder_11] => 0 [:db_insert_placeholder_12] => 0 [:db_insert_placeholder_13] => 0 ) dans drupal_write_record() (ligne 7136 dans /var/www/carioca/includes/common.inc).

I have checked the database and the last node id is 294.

Does anyone have an idea how to solve this issue ?

Thanks for your help.

2

2 Answers

1
votes

If you have a PhpMyAdmin for your Database, have a look at the tables: node & node_revision. Could be that you have different indexes in there and causes that the id cannot be inserted.

Your issue is not that there is already an entry in the DB but that node & node_revision (or other table) has different state as the other tables does. The data within your DB seems to not be consistent.

Are you having custom table handles within your modules? Fix the Id issues and use the node_load or user_load Drupal API functions instead of custom DB calls.

If you are on Drupal 6 have a look into the node_counter table where there could be a older value.

-1
votes

When executing the following mysql query, do you have a result?

SELECT * FROM node WHERE nid = 308;