Fixed Having 2 User group promotions pointing to a single UserGroup got this errors

rdn

Well-known member
Affected version
2.1.11
So I have additional UserGroup, Level 1 < Level 2 < Level 3.
Each level has different permissions and also each level has 2 User group promotions pointed to them.
Main difference on the promotion is only for "User has been registered for at least X days".
New users has more more requirements and older members has few requirements only.

I got 20+ of this errors today:
Code:
######################################
XF\Db\DuplicateKeyException: MySQL query error [1062]: Duplicate entry '11-578015' for key 'PRIMARY' src/XF/Db/AbstractStatement.php:228
Generated by: User1 Sep 22, 2020 at 12:28 PM
Stack trace
INSERT  INTO `xf_user_group_promotion_log` (`promotion_id`, `user_id`, `promotion_date`, `promotion_state`) VALUES (?, ?, ?, ?)
------------

#0 src/XF/Db/Mysqli/Statement.php(196): XF\Db\AbstractStatement->getException()
#1 src/XF/Db/Mysqli/Statement.php(77): XF\Db\Mysqli\Statement->getException()
#2 src/XF/Db/AbstractAdapter.php(94): XF\Db\Mysqli\Statement->execute()
#3 src/XF/Db/AbstractAdapter.php(218): XF\Db\AbstractAdapter->query()
#4 src/XF/Mvc/Entity/Entity.php(1463): XF\Db\AbstractAdapter->insert()
#5 src/XF/Mvc/Entity/Entity.php(1195): XF\Mvc\Entity\Entity->_saveToSource()
#6 src/XF/Entity/UserGroupPromotion.php(44): XF\Mvc\Entity\Entity->save()
#7 src/XF/Repository/UserGroupPromotion.php(115): XF\Entity\UserGroupPromotion->promote()
#8 src/XF/Pub/App.php(236): XF\Repository\UserGroupPromotion->updatePromotionsForUser()
#9 src/XF/Pub/App.php(189): XF\Pub\App->updateUserCaches()
#10 src/XF/App.php(2187): XF\Pub\App->start()
#11 src/XF.php(391): XF\App->run()
#12 index.php(20): XF::runApp()
#13 {main}
Request state
array(4) {
  ["url"] => string(17) "/login/keep-alive"
  ["referrer"] => string(113) "https://dom.in/threads/title.947498/"
  ["_GET"] => array(1) {
    ["/login/keep-alive"] => string(0) ""
  }
  ["_POST"] => array(2) {
    ["_xfResponseType"] => string(4) "json"
    ["_xfToken"] => string(8) "********"
  }
}

######################################
XF\Db\DuplicateKeyException: MySQL query error [1062]: Duplicate entry '11-89828' for key 'PRIMARY' src/XF/Db/AbstractStatement.php:228
Generated by: User2 Sep 22, 2020 at 9:49 AM
Stack trace
INSERT  INTO `xf_user_group_promotion_log` (`promotion_id`, `user_id`, `promotion_date`, `promotion_state`) VALUES (?, ?, ?, ?)
------------

#0 src/XF/Db/Mysqli/Statement.php(196): XF\Db\AbstractStatement->getException()
#1 src/XF/Db/Mysqli/Statement.php(77): XF\Db\Mysqli\Statement->getException()
#2 src/XF/Db/AbstractAdapter.php(94): XF\Db\Mysqli\Statement->execute()
#3 src/XF/Db/AbstractAdapter.php(218): XF\Db\AbstractAdapter->query()
#4 src/XF/Mvc/Entity/Entity.php(1463): XF\Db\AbstractAdapter->insert()
#5 src/XF/Mvc/Entity/Entity.php(1195): XF\Mvc\Entity\Entity->_saveToSource()
#6 src/XF/Entity/UserGroupPromotion.php(44): XF\Mvc\Entity\Entity->save()
#7 src/XF/Repository/UserGroupPromotion.php(115): XF\Entity\UserGroupPromotion->promote()
#8 src/XF/Pub/App.php(236): XF\Repository\UserGroupPromotion->updatePromotionsForUser()
#9 src/XF/Pub/App.php(189): XF\Pub\App->updateUserCaches()
#10 src/XF/App.php(2187): XF\Pub\App->start()
#11 src/XF.php(391): XF\App->run()
#12 index.php(20): XF::runApp()
#13 {main}
Request state
array(4) {
  ["url"] => string(17) "/login/keep-alive"
  ["referrer"] => string(93) "https://dom.in/threads/title.69432/"
  ["_GET"] => array(1) {
    ["/login/keep-alive"] => string(0) ""
  }
  ["_POST"] => array(2) {
    ["_xfResponseType"] => string(4) "json"
    ["_xfToken"] => string(8) "********"
  }
}
 
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 XF release (2.2.0 RC2).

Change log:
Prevent an error related to a user group promotion race condition
There may be a delay before changes are rolled out to the XenForo Community.
 
Just to clarify, this doesn't have any relation to your promotion setup. It appears to just be a race condition, so the most likely cause of these errors -- especially if you got a burst today -- is server load issues (expanding the race condition to a level that is significant).
 
Top Bottom