Skip to content

Conversation

@sureshanaparti
Copy link
Contributor

Description

This PR allows the limit queries without random ordering.

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?

@sureshanaparti sureshanaparti changed the base branch from main to 4.20 February 5, 2026 14:04
@sureshanaparti sureshanaparti changed the title Db filter with limit Allow limit queries without random ordering Feb 5, 2026
@sureshanaparti sureshanaparti added this to the 4.20.3 milestone Feb 5, 2026
@sureshanaparti
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@sureshanaparti 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.

@DaanHoogland
Copy link
Contributor

@sureshanaparti , what are we using this for? It is a framework level change without usage, I am really wondering.

@codecov
Copy link

codecov bot commented Feb 5, 2026

Codecov Report

❌ Patch coverage is 30.00000% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 4.15%. Comparing base (3d7d412) to head (65761f7).
⚠️ Report is 1 commits behind head on 4.20.

Files with missing lines Patch % Lines
...c/main/java/com/cloud/utils/db/GenericDaoBase.java 0.00% 3 Missing ⚠️
...rk/db/src/main/java/com/cloud/utils/db/Filter.java 60.00% 1 Missing and 1 partial ⚠️
.../src/main/java/com/cloud/host/dao/HostDaoImpl.java 0.00% 1 Missing ⚠️
...dstack/storage/datastore/db/ImageStoreDaoImpl.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##               4.20   #12598       +/-   ##
=============================================
- Coverage     16.26%    4.15%   -12.11%     
=============================================
  Files          5661      404     -5257     
  Lines        500010    32965   -467045     
  Branches      60715     5893    -54822     
=============================================
- Hits          81331     1370    -79961     
+ Misses       409606    31419   -378187     
+ Partials       9073      176     -8897     
Flag Coverage Δ
uitests 4.15% <ø> (ø)
unittests 17.12% <30.00%> (+<0.01%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 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.

@sureshanaparti
Copy link
Contributor Author

@sureshanaparti , what are we using this for? It is a framework level change without usage, I am really wondering.

random sorting may not be required in all cases. It requires the use of a temporary table for the sort, which is taking more time for a simple lookup by name of a VM.

@winterhazel
Copy link
Member

@sureshanaparti , what are we using this for? It is a framework level change without usage, I am really wondering.

@DaanHoogland there are some usages for it. I used an alternative approach in 02d8f18 for batch expunge. That one line in GenericDaoBase may be changed to filter = new Filter(batchSizeFinal, false);

@winterhazel
Copy link
Member

winterhazel commented Feb 5, 2026

@sureshanaparti btw, I think that it may be good to change the usages of Filter(long limit) to Filter(long limit, true) for the sake of clarity, and either remove Filter(long limit) or change it to this(limit, false) to avoid unintended behavior in the future

@DaanHoogland
Copy link
Contributor

ok, guys, I see how it could have been useful for instance in @winterhazel ’s change. In this PR however it is not used at all. Are we planning to …?

@blueorangutan
Copy link

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

@borisstoyanov borisstoyanov self-assigned this Feb 9, 2026
@sureshanaparti
Copy link
Contributor Author

@sureshanaparti btw, I think that it may be good to change the usages of Filter(long limit) to Filter(long limit, true) for the sake of clarity, and either remove Filter(long limit) or change it to this(limit, false) to avoid unintended behavior in the future

@winterhazel there are references with Filter(1) and random sorting doesn't make sense there, updated Filter(long limit) to call this(limit, false).

@sureshanaparti
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@sureshanaparti 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.

@sureshanaparti
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@sureshanaparti 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.

@blueorangutan
Copy link

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

@blueorangutan
Copy link

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

@winterhazel
Copy link
Member

winterhazel commented Feb 9, 2026

@sureshanaparti btw, I think that it may be good to change the usages of Filter(long limit) to Filter(long limit, true) for the sake of clarity, and either remove Filter(long limit) or change it to this(limit, false) to avoid unintended behavior in the future

@winterhazel there are references with Filter(1) and random sorting doesn't make sense there, updated Filter(long limit) to call this(limit, false).

@sureshanaparti the random sorting does make sense in com.cloud.utils.db.GenericDaoBase#lockOneRandomRow, com.cloud.utils.db.GenericDaoBase#findOneIncludingRemovedBy, com.cloud.host.dao.HostDaoImpl#findAnyStateHypervisorHostInCluster, and org.apache.cloudstack.storage.datastore.db.ImageStoreDaoImpl#findOneByZoneAndProtocol. Could you update those to call Filter(1, true) to restore the previous behavior?

@sureshanaparti
Copy link
Contributor Author

@sureshanaparti btw, I think that it may be good to change the usages of Filter(long limit) to Filter(long limit, true) for the sake of clarity, and either remove Filter(long limit) or change it to this(limit, false) to avoid unintended behavior in the future

@winterhazel there are references with Filter(1) and random sorting doesn't make sense there, updated Filter(long limit) to call this(limit, false).

@sureshanaparti the random sorting does make sense in com.cloud.utils.db.GenericDaoBase#lockOneRandomRow, com.cloud.utils.db.GenericDaoBase#findOneIncludingRemovedBy, com.cloud.host.dao.HostDaoImpl#findAnyStateHypervisorHostInCluster, and org.apache.cloudstack.storage.datastore.db.ImageStoreDaoImpl#findOneByZoneAndProtocol. Could you update those to call Filter(1, true) to restore the previous behavior?

oh sorry, correct. I'll check and update. thanks @winterhazel

Copy link
Contributor

@borisstoyanov borisstoyanov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sureshanaparti
Copy link
Contributor Author

@sureshanaparti btw, I think that it may be good to change the usages of Filter(long limit) to Filter(long limit, true) for the sake of clarity, and either remove Filter(long limit) or change it to this(limit, false) to avoid unintended behavior in the future

@winterhazel there are references with Filter(1) and random sorting doesn't make sense there, updated Filter(long limit) to call this(limit, false).

@sureshanaparti the random sorting does make sense in com.cloud.utils.db.GenericDaoBase#lockOneRandomRow, com.cloud.utils.db.GenericDaoBase#findOneIncludingRemovedBy, com.cloud.host.dao.HostDaoImpl#findAnyStateHypervisorHostInCluster, and org.apache.cloudstack.storage.datastore.db.ImageStoreDaoImpl#findOneByZoneAndProtocol. Could you update those to call Filter(1, true) to restore the previous behavior?

oh sorry, correct. I'll check and update. thanks @winterhazel

updated @winterhazel

@sureshanaparti
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@sureshanaparti 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.

@blueorangutan
Copy link

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

Copy link
Contributor

@DaanHoogland DaanHoogland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clgtm

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.

5 participants