Unexpected output: Affected paths: relative - resubmit patch.
⚙ D141 MINC-134 - Lock tables to generate unique order numbers
Page MenuHomeIn-Portal Phabricator

MINC-134 - Lock tables to generate unique order numbers
ClosedPublic

Authored by alex on Sep 28 2015, 9:03 AM.

Details

Test Plan

Below I'll explain how I've replicated racing condition. Feel free to use other preferred method if needed.

in Admin Console:

  • create a tangible product
  • create an Incomplete order (can be without products as well)
  • go to ConfigurationE-commerceGeneral section
  • confirm, that Comm_Next_Order_Number system setting value is 2 (if you've created orders before it will be last order number plus one)
  • try entering larger value (e.g. 5)
  • confirm, that value is saved
  • try entering lower value (lower, than last created order number)
  • confirm, that validation error is shown exposing actual minimal value that can be entered in that field

in PhpStorm

  • enable debugger
  • make sure that parallel debug is enabled:
  • put breakpoint on the line where LOCK ... statement is in changed code

on Front-End

  1. open 2 browser tabs (one normal and one private so that cookies are not shared)
  2. in each tab:
    • go to category category where product as added
    • enable Xdebug
    • press Buy Now button
  3. confirm, that 2 debug connections were created in PhpStorm
  4. allow the LOCK ... sql to be executed in 1st debug session
  5. allow the LOCK ... sql to be executed in 2nd debug session
  6. confirm, that in 2nd debug session debugging is impossible due attempt of lock tables, that are already locked
  7. confirm, that you can open any of Configuration section (that read from SystemSettings table) in the Admin Console
  8. let code from both debug sessions be executed till the end
  9. confirm, that:
    • both created orders have different Number column value
    • the value of Comm_Next_Order_Number system setting (in ConfigurationE-commerceGeneral section) has next available order number (+1 then last used one)

Diff Detail

Repository
rINP In-Portal
Branch
/in-portal/branches/5.2.x
Lint
Lint OK
Unit
No Unit Test Coverage
Build Status
Buildable 196
Build 196: arc lint + arc unit

Event Timeline

alex updated this revision to Diff 352.Sep 28 2015, 9:03 AM
alex retitled this revision from to MINC-134 - Lock tables to generate unique order numbers.
alex updated this object.
alex edited the test plan for this revision. (Show Details)
alex added 1 JIRA issue(s): MINC-134.
alex edited the test plan for this revision. (Show Details)Sep 28 2015, 9:10 AM
alex edited edge metadata.
alex edited the test plan for this revision. (Show Details)
alex updated this revision to Diff 353.Sep 28 2015, 9:34 AM

Only lock SystemSettings table, when generating next order number.

alex edited the test plan for this revision. (Show Details)Sep 28 2015, 10:00 AM
alex updated this revision to Diff 354.Sep 28 2015, 10:10 AM

Only call SetConfigValue method once locks were released, because it can write to non-locked tables.

glebs accepted this revision.Oct 1 2015, 1:45 AM
glebs edited edge metadata.
This revision is now accepted and ready to land.Oct 1 2015, 1:45 AM
This revision was automatically updated to reflect the committed changes.
alex edited edge metadata.Mar 10 2016, 5:43 AM
alex added a project: Restricted Project.