+ Reply to Thread
Results 1 to 6 of 6

Thread: MDB2 Error: constraint violation

  1. #1
    Laze is offline Registered User
    Join Date
    Sep 2009
    Posts
    6
    Downloads
    0
    Uploads
    0

    Red face MDB2 Error: constraint violation

    Actual 0.3.1

    I quite often get these errors:

    [10-Dec-2009 08:10:46] MDB2 Error: constraint violation (-3): _doQuery: [Error message: Could not execute statement]
    [Last executed query: EXECUTE mdb2_statement_mysql_43f1d87d2ce79a0dd5349aa9dea0a 7063c855cf83 USING @0, @1, @2, @3, @4, @5, @6, @7, @8, @9, @10]
    [Native code: 1062]
    [Native message: Duplicate entry '120-INBOX.msg-3852' for key 2]

    [10-Dec-2009 08:10:46 +0100]: DB Error: MDB2 Error: constraint violation Query: _doQuery: [Error message: Could not execute statement] [Last executed query: EXECUTE mdb2_statement_mysql_43f1d87d2ce79a0dd5349aa9dea0a 7063c855cf83 USING @0, @1, @2, @3, @4, @5, @6, @7, @8, @9, @10] [Native code: 1062] [Native message: Duplicate entry '120-INBOX.msg-3852' for key 2] in /var/www/htdocs/program/include/rcube_mdb2.php on line 627 (GET /?_task=mail&_action=get&_uid=3852&_mbox=INBOX&_par t=3)


    I have tried the fowlloing:
    Truncate both cache and messages tables.
    Everything is updated

    Could anybody please, please help with this and point me which is causing this ? Its driving me mad!

  2. #2
    Laze is offline Registered User
    Join Date
    Sep 2009
    Posts
    6
    Downloads
    0
    Uploads
    0

    Default

    A bit more data
    Code:
    INSERT INTO messages
             (user_id, del, cache_key, created, idx, uid, subject, `from`, `to`, cc, date, size, headers, structure)
             VALUES (?, 0, ?, now(), ?, ?, ?, ?, ?, ?, FROM_UNIXTIME(1260435211), ?, ?, ?)
    
    Values being inserted:
    
    Array
    (
        [0] => 104
        [1] => INBOX.msg
        [2] => 4
        [3] => 1808
        [4] => xxxxxxxxxxxxxxx
        [5] => xxxxxxxxxx <xxxx@xxxx.dk>
        [6] => xxxxx <xxx@xxx.dk>
        [7] =>
        [8] => 34777
        [9] => O:14:"iilBasicHeader":32:{s:2:"id";s:1:"4";s:3:"uid";s:4:"1808";s:7:"subject";s:38:"xxxxxxxxxxxxxxxxxxxx";s:4:"from";s:30:""xxxxxxxx" <xxxx@xxxx.dk>";s:2:"to";s:47:""xxxxxx" <xxx@xxx.dk>";s:2:"cc";s:0:"";s:7:"replyto";s:0:"";s:11:"in_reply_to";s:0:"";s:4:"date";s:31:"Thu, 10 Dec 2009 09:53:31 +0100";s:9:"messageID";s:61:"<81298A2C5763F8489CF3F0F23B3F817502CB1AFD@ac-s1.AaenCo.local>";s:4:"size";s:5:"34777";s:8:"encoding";s:0:"";s:7:"charset";s:0:"";s:5:"ctype";s:17:"multipart/related";s:5:"flags";a:1:{i:0;s:4:"Seen";}s:9:"timestamp";s:10:"1260435211";s:1:"f";s:0:"";s:14:"body_structure";s:637:"((("text" "plain" ("charset" "iso-8859-1") NIL NIL "quoted-printable" 3266 113 NIL NIL NIL NIL)("text" "html" ("charset" "iso-8859-1") NIL NIL "quoted-printable" 18130 483 NIL NIL NIL NIL) "alternative" ("boundary" "----_=_NextPart_002_01CA7976.3FF2F363") NIL NIL NIL)("image" "jpeg" ("name" "image007.jpg") "<image007.jpg@01C9BD53.5F90F340>" "image007.jpg" "base64" 2974 NIL NIL NIL "image007.jpg")("image" "jpeg" ("name" "image003.jpg") "<image003.jpg@01CA4B29.6F667B50>" "image003.jpg" "base64" 6714 NIL NIL NIL "image003.jpg") "related" ("boundary" "----_=_NextPart_001_01CA7976.3FF2F363" "type" "multipart/alternative") NIL NIL NIL)";s:12:"internaldate";s:26:"10-Dec-2009 09:53:38 +0100";s:10:"references";s:0:"";s:8:"priority";s:0:"";s:6:"mdn_to";s:0:"";s:8:"mdn_sent";s:0:"";s:8:"is_draft";s:0:"";s:4:"seen";s:1:"1";s:7:"deleted";s:0:"";s:6:"recent";s:0:"";s:8:"answered";s:0:"";s:9:"forwarded";s:0:"";s:4:"junk";s:0:"";s:7:"flagged";s:0:"";s:6:"others";a:0:{}}
        [10] =>
    )
    Last edited by Laze; 12-10-2009 at 09:52 AM.

  3. #3
    skaero's Avatar
    skaero is online now Administrator
    Join Date
    Jun 2006
    Location
    USA - New Mexico
    Posts
    2,092
    Downloads
    5
    Uploads
    0

    Default

    Does this happen with a fresh install?

  4. #4
    Laze is offline Registered User
    Join Date
    Sep 2009
    Posts
    6
    Downloads
    0
    Uploads
    0

    Default

    Its a freshly upgraded to 0.3.1 - we are unable to do a complete new install - this would remove existing users.

    It seems like its trying to insert the same record again.
    Last edited by Laze; 12-10-2009 at 01:45 PM.

  5. #5
    skaero's Avatar
    skaero is online now Administrator
    Join Date
    Jun 2006
    Location
    USA - New Mexico
    Posts
    2,092
    Downloads
    5
    Uploads
    0

    Default

    Can you test it with a different database?

  6. #6
    Laze is offline Registered User
    Join Date
    Sep 2009
    Posts
    6
    Downloads
    0
    Uploads
    0

    Default

    We have fixed it with a quick and dirty patch - this doesn't work with other databases than MySQL - should probally be MDB2 - InstallationWiki or a delete before the insert.

    The add_message_cache function seems to be bad due to the fact that you can force it to insert into the table without it checking if the data is already present.

    But there ie

    Code:
    --- program/include/rcube_imap.php      (revision 66)
    +++ program/include/rcube_imap.php      (working copy)
    @@ -2514,7 +2514,7 @@
         else  // insert new record
           {
           $this->db->query(
    -        "INSERT INTO ".get_table_name('messages')."
    +        "REPLACE INTO ".get_table_name('messages')."
              (user_id, del, cache_key, created, idx, uid, subject, ".$this->db->quoteIdentifier('from').", ".$this->db->quoteIdentifier('to').", cc, date, size, headers, structure)
              VALUES (?, 0, ?, ".$this->db->now().", ?, ?, ?, ?, ?, ?, ".$this->db->fromunixtime($headers->timestamp).", ?, ?, ?)",
             $_SESSION['user_id'],

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts