Date corruption on data export task when threads > 1
Description
When database export tasks are executed with a "Maximum Threads" count greater than 1, data corruption occurs for Date and Time types, producing date strings with invalid years, days, and months such as April 31.
This occurs with multiple input and output drivers.
Log files contain customer data, so can be sanitized and provided on request.
DBeaver Version
Enterprise Edition 25.2.0
Operating System
CentOS x86_64
Database and driver
Experienced with the following as source:
Oracle 12c: Oracle JDBC driver 23.2.0.0.0 DB2 UDB for AS/400 07.05.0000 V7R5m0: AS/400 Toolbox for Java JDBC Driver 13.3
Export destination:
PostgreSQL 16.8: PostgreSQL JDBC Driver 42.7.2 Filesystem file as INSERT statements
Steps to reproduce
Create a Data Export task containing multiple tables with Date columns. All tables set with existing mapping to destination.
Y - Open New Connection N - Select Row Count Fetch Size: 100000 Maximum Threads: >1 (set 4+ to repo, but experienced with 2) Extract type: Single query
Y - Open new connections Y - Use transactions Y - Disable referential integrity Replace method: ON CONFLICT DO NOTHING Commit after: 100,000 Multi-row insert: 500 N - Disable batches N - Use bulk load
With this configuration you will begin to see errors with date values for insert, with invalid dates like '2024-02-30' and '2021-04-31'. Checking the source databases, there are no such data issues. When run with a thread count of 1 the task completes successfully.
The erroneous date appears in the logged INSERT ON CONFLICT statement. Due to data sensitivity I cannot publicly share the statement. Other dates are also being mangled, but are not causing errors due to the produced date string conforming with the calendar.
My best guess is that, since this occurring with multiple source database types on their latest drivers, this is occurring in the intermediate conversion form in StreamTransferConsumer due to the use of non-threadsafe SimpleDateFormat, but I am not currently in the position to produce an instrumented DBeaver build.
Additional context
This was first seen in DBeaver 23.x, but was written off as an issue with the IBMi DB2 driver in use at the time. This is readily possible to reproduce in our environment.
Source: dbeaver/dbeaver