sap-commerce-db-sync
sap-commerce-db-sync copied to clipboard
NPE when Source DB Timezone is not specified
Accessing /migrationData from the HAC will throw an NPE in case of Source DB's Timezone is not specified.
Class/Method:
CommercemigrationhacController#checkTimeZoneDifferences()
Code:
TimeZone source = TimeZone.getTimeZone(context.getDataSourceRepository().getDatabaseTimezone());
I think, this method can consider this case of 'No timezone difference' as it does not stop the migration in any case.
Please specify information about source database. Also null timezone is only possible when DB query failed to obtain such information, there should be additional error message in log, however I see that exception "handling" in that part of code is quite, well, non existing (ex. MySQLDataRepository.java:152)
Source DB is HANA.
Yes, it doesn't log. If not being able to retrieve the timezone from the source DB should ideally throw an error or at least warn because without that migration cannot really happen?
Timezone information is important to not get potential data corruption on all date/time columns, but for sure this logic needs some improvements.
Can you confirm that you're not able to execute following query:
select * from M_HOST_INFORMATION where upper(KEY) like '%TIMEZONE_NAME%'
It should not be prohibited for correctly configured HANA DB user
Hi @lnowakowski , i have the same/similar issue . Also on HANA DB as Source DB. When clicking on the HAC "data migration" page, a 500 Server Error occurs. When checking per Dynatrace, i see CommercemigrationhacController.checkTimeZoneDifferences has an NPE (Cannot invoke "String.length()" because "id" is null) java.util.TimeZone.parseCustomTimeZone (TimeZone.java:801)[-] java.util.TimeZone.getTimeZone (TimeZone.java:580) java.util.TimeZone.getTimeZone (TimeZone.java:518) de.hybris.platform.hac.controller.CommercemigrationhacController.checkTimeZoneDifferences (CommercemigrationhacController.java:547)
When calling the above query in the HANA DB directly i get one result : "CET" .
Hello @Otiom, thank you for your input. I'd like to ask you for more details, because in case of such error, I'd implement a fallback to default UTC time zone for example, which in your case would create a big issue as your DB is on CET. Can you confirm that given SQL query was executed with same user credentials as ones used in DB Sync? It's quite strange that queried from DB Sync gives an error, but still we'll implement some better exception handling there to get more details about problem root cause
Hello @lnowakowski, you were right. The inital rights did not allow this query. This was now changed. We will soon try again and let you know.
My suggestion would be to include this query call also in the "connection check" and in case it fails provide a useful message on what to check.
In case a fallback to a timezone is still for other things needed: Maybe an option to overwrite per property with the fitting timezone (and default UTC) would be an option.
Maybe an option to overwrite per property with the fitting timezone (and default UTC) would be an option.
Yeah, good idea. Thanks, will try to include it in upcoming changes