Bug Duplicate Keys

Status
Not open for further replies.

AluminumPints

Customer
I keep getting this error in the mornings after I change 2 drives to active that drop off my list ... i fix them to active and save and they will display properly until this cron tab runs and throws the error and the 2 drives are dropped from the list.

Code:
XF\Db\DuplicateKeyException: MySQL query error [1062]: Duplicate entry '5-1595044800-1598241600' for key 'PRIMARY' src/XF/Db/AbstractStatement.php:228
Generated by: Unknown account Sep 12, 2020 at 8:05 PM
Stack trace
INSERT  INTO `xf_dbtech_donate_drive_history` (`drive_id`, `start_dateline`, `end_dateline`, `goal_amount`, `collected_amount`) VALUES (?, ?, ?, ?, ?)
------------

#0 src/XF/Db/Mysqli/Statement.php(196): XF\Db\AbstractStatement->getException('MySQL query err...', 1062, '23000')
#1 src/XF/Db/Mysqli/Statement.php(77): XF\Db\Mysqli\Statement->getException('MySQL query err...', 1062, '23000')
#2 src/XF/Db/AbstractAdapter.php(94): XF\Db\Mysqli\Statement->execute()
#3 src/XF/Db/AbstractAdapter.php(221): XF\Db\AbstractAdapter->query('INSERT  INTO `x...', Array)
#4 src/XF/Mvc/Entity/Entity.php(1510): XF\Db\AbstractAdapter->insert('xf_dbtech_donat...', Array, false)
#5 src/XF/Mvc/Entity/Entity.php(1242): XF\Mvc\Entity\Entity->_saveToSource()
#6 src/addons/DBTech/Donate/Service/Drive/Expire.php(203): XF\Mvc\Entity\Entity->save(false)
#7 src/XF/Service/ValidateAndSavableTrait.php(40): DBTech\Donate\Service\Drive\Expire->_save()
#8 src/addons/DBTech/Donate/Repository/Drive.php(93): DBTech\Donate\Service\Drive\Expire->save()
#9 src/addons/DBTech/Donate/Cron/Donate.php(29): DBTech\Donate\Repository\Drive->updateExpiredDrives()
#10 [internal function]: DBTech\Donate\Cron\Donate::updateExpiredDrives(Object(XF\Entity\CronEntry))
#11 src/XF/Job/Cron.php(35): call_user_func(Array, Object(XF\Entity\CronEntry))
#12 src/XF/Job/Manager.php(258): XF\Job\Cron->run(G)
#13 src/XF/Job/Manager.php(200): XF\Job\Manager->runJobInternal(Array, G)
#14 src/XF/Job/Manager.php(84): XF\Job\Manager->runJobEntry(Array, G)
#15 job.php(43): XF\Job\Manager->runQueue(false, 8)
#16 {main}
 
Can you please describe exactly what you edited in the drive settings? It sounds like you may have tweaked the dates around, causing the system to think the same start/end date stamps happened twice.
 
hmmm i did change some of the dates in settings ... what field is that in the database perhaps i can see if there are duplicates ?
 
That information is in the error message :)

Table: xf_dbtech_donate_drive_history
Data: 5-1595044800-1598241600 for the columns drive_id, start_dateline, end_dateline

You'll have to delete those entries and re-run the cron until it completes without errors.

Also, if I'm to permanently fix this, I will need to know the exact steps you took, not just "I changed something" :p
 
just changed the end dates i noticed two of them were overlapping ... made the change in the control panel not in the db.
 
Can you please be more specific? I can't replicate the issue without the details.

Thank you.
 
No, the drive IDs are not different. You need to delete the entries listed in the error message as I described in my previous post.
 
i will try.

i keep all the drives "active" so they sort of display as a history on the drive page ... there are 6 of them. and they start and end for a month but not exactly ...

i had noticed that two of the drives the end date of the drive overlapped with the start date of the next drive. so i fixed the dates and ran the cache job to update the drives.

all was well until in the morning this error appeared

i wish i could be more specific but that is really all i changed to the best of my recollection
 
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future release (v3.3.0).

Change log:
Fix: Catch a DuplicateKeyException if the drive dates are changed around

 
Status
Not open for further replies.

DragonByte Donate

XenForo 1.5.3+ XenForo 2.0.x XenForo 2.1.x XenForo 2.2.x
Seller
DragonByte Technologies
Release date
Last update
Total downloads
1,538
Customer rating
5.00 star(s) 1 ratings
Back
Top