Skip to content

server: use id column as secondary sort criteria with sortKey - #5320

Merged
yadvr merged 1 commit into
apache:mainfrom
shapeblue:fix-listapi-usesortkey
Aug 18, 2021
Merged

server: use id column as secondary sort criteria with sortKey #5320
yadvr merged 1 commit into
apache:mainfrom
shapeblue:fix-listapi-usesortkey

Conversation

@shwstppr

@shwstpprshwstppr commented Aug 16, 2021

Copy link
Copy Markdown
Contributor

Description

For tables that use sort_key field, incorrect results can be returned by the list* APIs while using pagination and with the same values for sort-key field. (Default value for sort_key field remains 0).
This change adds id column as secondary sort criteria in such cases.

Fixes#5316

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)

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?

  • Created 1000 disk offerings
  • Listed 500 disk offerings ids using cmk at a time for 2 pages
  • Verified if there are any duplicates
  • No duplicates found

diskoffering-fix.log

@shwstppr

Copy link
Copy Markdown
ContributorAuthor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@shwstppr a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result: ✔️ el7 ✔️ el8 ✔️ debian. SL-JID 884

@nvazquez

Copy link
Copy Markdown
Contributor

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

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

@shwstpprshwstppr reopened this Aug 16, 2021
@apacheapache deleted a comment from blueorangutanAug 16, 2021
@apacheapache deleted a comment from blueorangutanAug 16, 2021
@apacheapache deleted a comment from blueorangutanAug 16, 2021
@shwstppr

Copy link
Copy Markdown
ContributorAuthor

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

@shwstppr a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests

@borisstoyanovborisstoyanov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM,

I've manually checked with ~1600 records and page size of 450, divided in 4 pages I could not get duplicates.

[root@pr5320-t1674-kvm-centos7-mgmt1 ~]# grep -x -i -f page1 page4 | wc
0 0 0
[root@pr5320-t1674-kvm-centos7-mgmt1 ~]# grep -x -i -f page2 page4 | wc
0 0 0
[root@pr5320-t1674-kvm-centos7-mgmt1 ~]# grep -x -i -f page3 page4 | wc
0 0 0
[root@pr5320-t1674-kvm-centos7-mgmt1 ~]# grep -x -i -f page1 page3 | wc
0 0 0
[root@pr5320-t1674-kvm-centos7-mgmt1 ~]# grep -x -i -f page1 page2 | wc
0 0 0
[root@pr5320-t1674-kvm-centos7-mgmt1 ~]# grep -x -i -f page3 page2 | wc
0 0 0

Lets wait for results from smoketests to appear.

@blueorangutan

Copy link
Copy Markdown

Trillian test result (tid-1671)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 65094 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr5320-t1671-kvm-centos7.zip
Intermittent failure detected: /marvin/tests/smoke/test_backup_recovery_dummy.py
Intermittent failure detected: /marvin/tests/smoke/test_global_settings.py
Intermittent failure detected: /marvin/tests/smoke/test_internal_lb.py
Intermittent failure detected: /marvin/tests/smoke/test_kubernetes_clusters.py
Intermittent failure detected: /marvin/tests/smoke/test_kubernetes_supported_versions.py
Intermittent failure detected: /marvin/tests/smoke/test_network.py
Intermittent failure detected: /marvin/tests/smoke/test_outofbandmanagement.py
Intermittent failure detected: /marvin/tests/smoke/test_projects.py
Intermittent failure detected: /marvin/tests/smoke/test_public_ip_range.py
Intermittent failure detected: /marvin/tests/smoke/test_reset_vm_on_reboot.py
Intermittent failure detected: /marvin/tests/smoke/test_resource_accounting.py
Intermittent failure detected: /marvin/tests/smoke/test_router_dhcphosts.py
Intermittent failure detected: /marvin/tests/smoke/test_router_dns.py
Intermittent failure detected: /marvin/tests/smoke/test_router_dnsservice.py
Intermittent failure detected: /marvin/tests/smoke/test_routers_iptables_default_policy.py
Intermittent failure detected: /marvin/tests/smoke/test_routers_network_ops.py
Intermittent failure detected: /marvin/tests/smoke/test_routers.py
Intermittent failure detected: /marvin/tests/smoke/test_secondary_storage.py
Intermittent failure detected: /marvin/tests/smoke/test_service_offerings.py
Intermittent failure detected: /marvin/tests/smoke/test_snapshots.py
Intermittent failure detected: /marvin/tests/smoke/test_ssvm.py
Intermittent failure detected: /marvin/tests/smoke/test_storage_policy.py
Intermittent failure detected: /marvin/tests/smoke/test_templates.py
Intermittent failure detected: /marvin/tests/smoke/test_usage.py
Intermittent failure detected: /marvin/tests/smoke/test_vm_deployment_planner.py
Intermittent failure detected: /marvin/tests/smoke/test_vm_life_cycle.py
Intermittent failure detected: /marvin/tests/smoke/test_vm_snapshots.py
Intermittent failure detected: /marvin/tests/smoke/test_volumes.py
Intermittent failure detected: /marvin/tests/smoke/test_vpc_redundant.py
Intermittent failure detected: /marvin/tests/smoke/test_vpc_router_nics.py
Intermittent failure detected: /marvin/tests/smoke/test_vpc_vpn.py
Intermittent failure detected: /marvin/tests/smoke/test_host_maintenance.py
Intermittent failure detected: /marvin/tests/smoke/test_hostha_kvm.py
Smoke tests completed. 57 look OK, 32 have error(s)
Only failed tests results shown below:

TestResultTime (s)Test File
test_UpdateConfigParamWithScopeError0.06test_global_settings.py
test_03_vpc_internallb_haproxy_stats_on_all_interfacesError3.24test_internal_lb.py
test_04_rvpc_internallb_haproxy_stats_on_all_interfacesError1.20test_internal_lb.py
ContextSuite context=TestDummyBackupAndRecovery>:setupError0.00test_backup_recovery_dummy.py
test_delete_accountError113.31test_network.py
ContextSuite context=TestCrossDomainAccountAdd>:setupError0.00test_projects.py
ContextSuite context=TestDeleteAccountWithProject>:setupError0.00test_projects.py
ContextSuite context=TestDeleteDomainWithProject>:setupError0.00test_projects.py
ContextSuite context=TestMultipleProjectCreation>:setupError0.00test_projects.py
ContextSuite context=TestProjectOwners>:setupError0.00test_projects.py
ContextSuite context=TestProjectResources>:setupError0.00test_projects.py
ContextSuite context=TestProjectSuspendActivate>:setupError0.00test_projects.py
ContextSuite context=TestKubernetesCluster>:setupError0.00test_kubernetes_clusters.py
ContextSuite context=TestKubernetesSupportedVersion>:setupError0.00test_kubernetes_supported_versions.py
test_oobm_multiple_mgmt_server_ownershipError0.16test_outofbandmanagement.py
ContextSuite context=TestResetVmOnReboot>:setupError0.00test_reset_vm_on_reboot.py
ContextSuite context=TestVPCRedundancy>:setupError0.00test_vpc_redundant.py
ContextSuite context=TestRAMCPUResourceAccounting>:setupError0.00test_resource_accounting.py
ContextSuite context=TestRouterDHCPHosts>:setupError0.00test_router_dhcphosts.py
ContextSuite context=TestRouterDHCPOpts>:setupError0.00test_router_dhcphosts.py
ContextSuite context=TestRouterDns>:setupError0.00test_router_dns.py
ContextSuite context=TestRouterDnsService>:setupError0.00test_router_dnsservice.py
ContextSuite context=TestCreateVolume>:setupError0.00test_volumes.py
ContextSuite context=TestVolumes>:setupError0.00test_volumes.py
ContextSuite context=TestRouterIpTablesPolicies>:setupError0.00test_routers_iptables_default_policy.py
ContextSuite context=TestVPCIpTablesPolicies>:setupError0.00test_routers_iptables_default_policy.py
ContextSuite context=TestIsolatedNetworks>:setupError0.00test_routers_network_ops.py
ContextSuite context=TestRedundantIsolateNetworks>:setupError0.00test_routers_network_ops.py
ContextSuite context=TestRouterServices>:setupError0.00test_routers.py
test_01_sys_vm_startFailure0.08test_secondary_storage.py
ContextSuite context=TestCpuCapServiceOfferings>:setupError0.00test_service_offerings.py
ContextSuite context=TestServiceOfferings>:setupError0.11test_service_offerings.py
ContextSuite context=TestSnapshotRootDisk>:setupError0.00test_snapshots.py
test_01_list_sec_storage_vmFailure0.03test_ssvm.py
test_02_list_cpvm_vmFailure0.02test_ssvm.py
test_03_ssvm_internalsFailure0.03test_ssvm.py
test_04_cpvm_internalsFailure0.02test_ssvm.py
test_05_stop_ssvmFailure0.02test_ssvm.py
test_06_stop_cpvmFailure0.02test_ssvm.py
test_07_reboot_ssvmFailure0.03test_ssvm.py
test_08_reboot_cpvmFailure0.02test_ssvm.py
test_09_reboot_ssvm_forcedFailure0.03test_ssvm.py
test_10_reboot_cpvm_forcedFailure0.03test_ssvm.py
test_11_destroy_ssvmFailure0.02test_ssvm.py
test_12_destroy_cpvmFailure0.02test_ssvm.py
ContextSuite context=TestVPCNics>:setupError0.00test_vpc_router_nics.py
ContextSuite context=TestVMWareStoragePolicies>:setupError0.00test_storage_policy.py
test_02_create_template_with_checksum_sha1Error65.35test_templates.py
test_03_create_template_with_checksum_sha256Error65.35test_templates.py
test_04_create_template_with_checksum_md5Error65.35test_templates.py
test_05_create_template_with_no_checksumError65.34test_templates.py
test_02_deploy_vm_from_direct_download_templateError1.18test_templates.py
ContextSuite context=TestTemplates>:setupError18.72test_templates.py
ContextSuite context=TestRVPCSite2SiteVpn>:setupError0.00test_vpc_vpn.py
ContextSuite context=TestVPCSite2SiteVPNMultipleOptions>:setupError0.00test_vpc_vpn.py
ContextSuite context=TestVpcRemoteAccessVpn>:setupError0.00test_vpc_vpn.py
ContextSuite context=TestVpcSite2SiteVpn>:setupError0.00test_vpc_vpn.py
ContextSuite context=TestISOUsage>:setupError0.00test_usage.py
ContextSuite context=TestLBRuleUsage>:setupError0.00test_usage.py
ContextSuite context=TestNatRuleUsage>:setupError0.00test_usage.py
ContextSuite context=TestPublicIPUsage>:setupError0.00test_usage.py
ContextSuite context=TestSnapshotUsage>:setupError0.00test_usage.py
ContextSuite context=TestVmUsage>:setupError0.00test_usage.py
ContextSuite context=TestVolumeUsage>:setupError0.00test_usage.py
ContextSuite context=TestVpnUsage>:setupError0.00test_usage.py
test_01_deploy_vm_on_specific_hostError2.89test_vm_deployment_planner.py
test_02_deploy_vm_on_specific_clusterError2.63test_vm_deployment_planner.py
test_03_deploy_vm_on_specific_podError2.71test_vm_deployment_planner.py
test_04_deploy_vm_on_host_override_pod_and_clusterError2.74test_vm_deployment_planner.py
test_05_deploy_vm_on_cluster_override_podError2.65test_vm_deployment_planner.py
ContextSuite context=TestDeployVM>:setupError0.00test_vm_life_cycle.py
test_01_secure_vm_migrationError77.26test_vm_life_cycle.py
test_02_unsecure_vm_migrationError217.74test_vm_life_cycle.py
test_03_secured_to_nonsecured_vm_migrationError145.98test_vm_life_cycle.py
test_04_nonsecured_to_secured_vm_migrationError145.84test_vm_life_cycle.py
ContextSuite context=TestVMLifeCycle>:setupError1.66test_vm_life_cycle.py
ContextSuite context=TestVmSnapshot>:setupError1.62test_vm_snapshots.py
test_02_cancel_host_maintenace_with_migration_jobsError1.45test_host_maintenance.py
test_03_cancel_host_maintenace_with_migration_jobs_failureError1.49test_host_maintenance.py
ContextSuite context=TestHostMaintenanceAgents>:setupError1.53test_host_maintenance.py
test_disable_oobm_ha_state_ineligibleError1511.77test_hostha_kvm.py

String name = column != null ? column.name() : field;

if (!name.equals("id")) {
name = String.format("%s, id", name);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM but I worry as this is used at so many places, @shwstppr - is there a more isolated way to fix the list API issue than this, i.e. what is causing the issue for the listServiceOfferings API response?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

@rhtyd as mentioned in the PR desc, it is sorting issue when entries in table have same value for the column (for which order by is called). In case of list* APIs where resources have sort_key in their corresponding tables.
Since by default value for sort_key is 0, weirdly sorted results are returned when LIMIT offset is used. Change will add id as secondary sort criteria.

Only issue I see is the case when table doesn't have id column. Don't think that is the case with tables in ACS.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What if the table has no id column @shwstppr the change is in Filter class and could have widespread side-effects. Can we check the service layer handler specific to listServiceOfferings and do something isolated/specific to that?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

@rhtyd changed the logic. No changes in Filter class now

For tables that use sort_key field, incorrect results can be returned by the list* APIs while using pagination and with the same values for sort-key field. (Default value for sort_key field remains 0).
This change adds id column as secondary sort criteria in such cases.
Fixesapache#5316
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
@shwstppr
shwstpprforce-pushed the fix-listapi-usesortkey branch from 137f37f to 169411eCompareAugust 17, 2021 12:36
@shwstpprshwstppr changed the title db: use id column as secondary sort criteriaserver: use id column as secondary sort criteria with sortKey Aug 17, 2021
@shwstppr

Copy link
Copy Markdown
ContributorAuthor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@shwstppr a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result: ✔️ el7 ✔️ el8 ✔️ debian. SL-JID 893

@weizhouapacheweizhouapache left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

code lgtm

@nvazqueznvazquez left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@weizhouapache

Copy link
Copy Markdown
Member

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

@weizhouapache a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests

@blueorangutan

Copy link
Copy Markdown

Trillian test result (tid-1680)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 34120 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr5320-t1680-kvm-centos7.zip
Intermittent failure detected: /marvin/tests/smoke/test_vpc_vpn.py
Smoke tests completed. 89 look OK, 0 have error(s)
Only failed tests results shown below:

TestResultTime (s)Test File

@nvazquez

Copy link
Copy Markdown
Contributor

@borisstoyanov can you please repeat your tests after the refactor?

@borisstoyanovborisstoyanov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, rerun the tests with latest changes and it all seems fine

[root@pr5320-t1674-kvm-centos7-mgmt1 ~]# grep -x -i -f page1 page2 | wc
0 0 0
[root@pr5320-t1674-kvm-centos7-mgmt1 ~]# grep -x -i -f page1 page3 | wc
0 0 0
[root@pr5320-t1674-kvm-centos7-mgmt1 ~]# grep -x -i -f page1 page4 | wc
0 0 0
[root@pr5320-t1674-kvm-centos7-mgmt1 ~]# grep -x -i -f page2 page4 | wc
0 0 0
[root@pr5320-t1674-kvm-centos7-mgmt1 ~]# grep -x -i -f page3 page4 | wc
0 0 0

@apacheapache deleted a comment from blueorangutanAug 18, 2021
@yadvryadvr added this to the 4.16.0.0 milestone Aug 18, 2021
@yadvr
yadvr merged commit 7bfc7f0 into apache:mainAug 18, 2021
Sign up for freeto 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.

paged listServiceOffering response returns duplicated records in different pages

6 participants

@shwstppr@blueorangutan@nvazquez@weizhouapache@yadvr@borisstoyanov