Any idea why the module would be trying to put a duplicate entry into the DB?

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '278170009317023744' for key 'PRIMARY': INSERT INTO {twitter} (twitter_id, screen_name, created_time, text, source, in_reply_to_status_id, in_reply_to_user_id, in_reply_to_screen_name, truncated) 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); Array ( [:db_insert_placeholder_0] => 278170009317023744 [:db_insert_placeholder_1] => BigOoga [:db_insert_placeholder_2] => 1355155873 [:db_insert_placeholder_3] => @sds52 Thank you for the RT LV! [:db_insert_placeholder_4] => TweetDeck [:db_insert_placeholder_5] => 278162857219223555 [:db_insert_placeholder_6] => 64223810 [:db_insert_placeholder_7] => sds52 [:db_insert_placeholder_8] => 0 ) in twitter_status_save() (line 145 of /var/www/www.sterndata.com/drupal/sites/all/modules/twitter/twitter.inc).

Comments

juampynr’s picture

Very weird, as tweets are saved using db_merge(), which checks if the entry exists to decide whether to update or insert. I will see if I can reproduce it.

juampynr’s picture

Status: Active » Postponed (maintainer needs more info)

Can't reproduce it. Did you upgrade the module? Which Twitter accounts have you got added? Which were authenticated and which not? Are you pulling mentions?

terry22’s picture

for info, I have the same problem.
with version 7.x-5.2 on an non authenticated account

PDOException : SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '281420135229710336' for key 1: INSERT INTO {twitter} (twitter_id, screen_name, created_time, text, source, in_reply_to_status_id, in_reply_to_user_id, in_reply_to_screen_name, truncated) 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); Array ( [:db_insert_placeholder_0] => 281420135229710336 [:db_insert_placeholder_1] => Andra_France [:db_insert_placeholder_2] => 1355930763 [:db_insert_placeholder_3] => Le potentiel géothermique profond de Bure n’est pas "exceptionnel" ! En page 4 du dernier Journal de l'Andra http://t.co/jYSymsHI [:db_insert_placeholder_4] => web [:db_insert_placeholder_5] => [:db_insert_placeholder_6] => 0 [:db_insert_placeholder_7] => [:db_insert_placeholder_8] => 0 ) dans twitter_status_save() (ligne 145 dans /home/xxxx/public_html/sites/all/modules/twitter/twitter.inc).

sterndata’s picture

I have only one twitter account set, @sds52, so it's the authenticated one. This is the only tweet that's having problems. I am pulling mentions.

The tweet is in the db - see http://www.sterndata.com/tweets?page=2

I may turn off mentions because it picks up the spammy tweets, too. Then, I have to go into the database and manually delete them.

baldwinlouie’s picture

I too have had this problem. I did some debugging and I found out that when I use Drupal and php, and its db_select(), or db_query() to query for a tweet by id, it is not returned. However, if I do it via the mysql cli, it returns fine.

To me, it seems like the twitter_id is getting screwed up by php before the sql query is ran.

Could this somehow be a php bug?

My environment is:
PHP 5.3.3-7+squeeze14
Debian Squeeze
Mysql: 5.1.61-0+squeeze1

Halian’s picture

I was having this issue but managed to fix it by changing the column to be DOUBLE instead of DECIMAL. Not sure if this is a valid solution but it seems to be working fine and I no longer get the error. I happened to stumble upon a post while looking into the db_merge command that led me to this solution.

dddave’s picture

Version: 7.x-5.2 » 7.x-5.x-dev
Status: Postponed (maintainer needs more info) » Active

Aaaand this issue is back from the semi-dead. Sorry!
Noticed that I get this error as a nice Cron-error (Cron finishes nonetheless). It seems that only this one tweet triggers the error but I don't know why. I have a couple of mentions and I don't see what makes this one special. This happens with PHP 5.3.17 btw.
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '335116869856022528' for key 'PRIMARY': INSERT INTO {twitter} (twitter_id, screen_name, created_time, text, source, in_reply_to_status_id, in_reply_to_user_id, in_reply_to_screen_name, truncated) 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); Array ( [:db_insert_placeholder_0] => 335116869856022528 [:db_insert_placeholder_1] => tsvenson [:db_insert_placeholder_2] => 1368733062 [:db_insert_placeholder_3] => @FromWayDowntown This is actually one of our best games in the tournament. Sad but true :( [:db_insert_placeholder_4] => <a href="http://www.tweetdeck.com" rel="nofollow">TweetDeck</a> [:db_insert_placeholder_5] => 335116620945051649 [:db_insert_placeholder_6] => 223421378 [:db_insert_placeholder_7] => FromWayDowntown [:db_insert_placeholder_8] => 0 ) in twitter_status_save() (Zeile 161 von /is/htdocs/XXXXXXX/www/drupal/sites/all/modules/twitter/twitter.inc).

dddave’s picture

Just wanted to add that this error has vanished as the tweet fall behind the threshold of tweets to fetch. So far only this one tweet caused this and I cannot figure out what made it special.

socialnicheguru’s picture

I get this too:

drush cron --debug

WD job_scheduler: Finished processing scheduled jobs (0 sec s, 0 [notice]
total, 0 failed). [58.22 sec, 134.02 MB]
WD cron: PDOException: SQLSTATE[23000]: Integrity constraint [error]
violation: 1062 Duplicate entry '336658084564963329' for key
'PRIMARY': INSERT INTO {twitter} (twitter_id, screen_name,
created_time, text, source, in_reply_to_status_id,
in_reply_to_user_id, in_reply_to_screen_name, truncated) 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); Array
(
[:db_insert_placeholder_0] => 336658084564963329
[:db_insert_placeholder_1] => voiceofandrea
[:db_insert_placeholder_2] => 1369100516
[:db_insert_placeholder_3] => Social Media & the Legal
Community is out! http://t.co/EN97gS1ntf ▸ Top stories today via
@SanzaySingh @chrisz210 @socialnicheguru
[:db_insert_placeholder_4] => Paper.li
[:db_insert_placeholder_5] =>
[:db_insert_placeholder_6] => 0
[:db_insert_placeholder_7] =>
[:db_insert_placeholder_8] => 0
)
in twitter_status_save() (line 161 of twitter/twitter.inc). [200.06 sec,
208.1 MB]

mcfilms’s picture

This just happened on my very first attempt to have Twitter post on my behalf... Same error: Integrity constraint violation: 1062

So I cannot evaluate if the next one will work on not.

chrisfree’s picture

Seeing the same issue on 7.x-5.8. Been pulling my hair out trying to figure out what the issue is. No luck yet.