Skip to content

Optimize OVS tunnel sequence numbers to use atomic SQL instead of row-level locks#13443

Open
nvazquez wants to merge 1 commit into
apache:4.22from
shapeblue:422-optimize-ovs-seq-numbers
Open

Optimize OVS tunnel sequence numbers to use atomic SQL instead of row-level locks#13443
nvazquez wants to merge 1 commit into
apache:4.22from
shapeblue:422-optimize-ovs-seq-numbers

Conversation

@nvazquez

Copy link
Copy Markdown
Contributor

Description

This PR replaces lockRow + Java increment + update pattern in getNextTopologyUpdateSequenceNumber and
getNextRoutingPolicyUpdateSequenceNumber with atomic SQL using LAST_INSERT_ID:

UPDATE ... SET seq_no = LAST_INSERT_ID(seq_no + 1) WHERE id = ?
SELECT LAST_INSERT_ID()

InnoDB serializes concurrent UPDATEs on the same row, and LAST_INSERT_ID(expr) stores the result in connection-local state, so each caller gets a unique monotonically increasing value without explicit row locks.

Also captures the return value of persist() in the find-or-create initialization path — the original code discarded it, relying on reflection to populate the ID field on the original object.

Removes the empty try/finally blocks from both methods.

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • Build/CI
  • Test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

How did you try to break this feature and the system with this change?

…-level locks

Replace lockRow + Java increment + update pattern in
getNextTopologyUpdateSequenceNumber and
getNextRoutingPolicyUpdateSequenceNumber with atomic SQL using
LAST_INSERT_ID:

  UPDATE ... SET seq_no = LAST_INSERT_ID(seq_no + 1) WHERE id = ?
  SELECT LAST_INSERT_ID()

InnoDB serializes concurrent UPDATEs on the same row, and
LAST_INSERT_ID(expr) stores the result in connection-local state,
so each caller gets a unique monotonically increasing value without
explicit row locks.

Also captures the return value of persist() in the find-or-create
initialization path — the original code discarded it, relying on
reflection to populate the ID field on the original object.

Removes the empty try/finally blocks from both methods.
@nvazquez

Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@nvazquez a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@codecov

codecov Bot commented Jun 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 25 lines in your changes missing coverage. Please review.
✅ Project coverage is 17.67%. Comparing base (8e933b7) to head (ef795ee).

Files with missing lines Patch % Lines
...work/ovs/dao/VpcDistributedRouterSeqNoDaoImpl.java 0.00% 13 Missing ⚠️
...va/com/cloud/network/ovs/OvsTunnelManagerImpl.java 0.00% 12 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               4.22   #13443      +/-   ##
============================================
- Coverage     17.67%   17.67%   -0.01%     
- Complexity    15792    15793       +1     
============================================
  Files          5922     5922              
  Lines        533167   533174       +7     
  Branches      65210    65211       +1     
============================================
- Hits          94246    94244       -2     
- Misses       428276   428284       +8     
- Partials      10645    10646       +1     
Flag Coverage Δ
uitests 3.69% <ø> (ø)
unittests 18.75% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 18290

@nvazquez

Copy link
Copy Markdown
Contributor Author

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

@nvazquez a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants