db: make *_details.value non-nullable#5274
db: make *_details.value non-nullable#5274nvazquez merged 2 commits intoapache:mainapache/cloudstack:mainfrom shapeblue:fix-details-table-nullable-valueshapeblue/cloudstack:fix-details-table-nullable-valueCopy head branch name to clipboard
Conversation
Fixes apache#4897 Some details tables were allowing null values for detail value which can cause NPE in some cases. mysql> SELECT TABLE_NAME, COLUMN_NAME, COLUMN_TYPE FROM information_schema.columns WHERE table_schema='cloud' AND table_name LIKE'%_details' AND column_name='value' AND IS_NULLABLE='YES'; +-------------------------------+-------------+---------------+ | TABLE_NAME | COLUMN_NAME | COLUMN_TYPE | +-------------------------------+-------------+---------------+ | account_details | value | varchar(255) | | cluster_details | value | varchar(255) | | data_center_details | value | varchar(1024) | | domain_details | value | varchar(255) | | image_store_details | value | varchar(255) | | storage_pool_details | value | varchar(255) | | template_deploy_as_is_details | value | text | | user_vm_deploy_as_is_details | value | text | | user_vm_details | value | varchar(5120) | +-------------------------------+-------------+---------------+ 9 rows in set (0.00 sec) Brings consistency for value column of *_details tables with preventing null values. Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
|
@blueorangutan package |
|
@weizhouapache a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
|
Packaging result: ✔️ el7 ✔️ el8 ✔️ debian. SL-JID 750 |
|
@blueorangutan test |
|
@weizhouapache a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
nvazquez
left a comment
There was a problem hiding this comment.
Code LGTM. I'm not aware of any case that will attempt to add a detail key with a null value on these tables
|
Trillian test result (tid-1473)
|
|
@blueorangutan test |
|
@nvazquez a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
|
Trillian Build Failed (tid-1526) |
|
@blueorangutan test |
|
@shwstppr a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
|
Trillian test result (tid-1535)
|
|
@blueorangutan test |
|
@rhtyd a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
|
Trillian test result (tid-1540)
|
|
@shwstppr can you please solve the conflict? |
There was a problem hiding this comment.
Code LGTM. I am +1 in having non-null values and I don't see any way of this PR causing regression issues.
However, I could not find why/how these values have been set to NULL.
Some of them seem to be created as NOT NULL values (see reate-schema.sql).
On the other hand, I could indeed find a case where the field was created without NOT NULL, such as template_deploy_as_is_details created in schema-41400to41500.sql.
Probably something that I am missing. Maybe a DB table change via Java or an upgrade schema-4XYto4XY+1.sql that would change values to NULL.
Has anyone mapped the cause of these NULL values? This question is just to avoid it happening again in the future.
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
|
@GabrielBrascher Some tables have been altered using upgrade SQL (very old change, not much there in commit message - c11dbad9c9b), https://github.com/apache/cloudstack/blob/main/engine/schema/src/main/resources/META-INF/db/schema-410to420.sql#L1873-L1876 Others were created without NOT NULL constraint. Not sure if was for some use-case or an oversight @blueorangutan package |
|
@shwstppr a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
|
Packaging result: ✔️ el7 ✔️ el8 ✔️ debian. SL-JID 860 |
|
@shwstppr looks like a couple of legacy SQL upgrades then, thanks for checking it. |
|
@blueorangutan test |
|
@nvazquez a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
|
Trillian test result (tid-1629)
|
Description
Fixes #4897
Some details tables were allowing null values for detail value which can cause NPE in some cases.
Brings consistency for value column of *_details tables with preventing null values.
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?