Altinity / clickhouse-backup

Tool for easy backup and restore for ClickHouse® using object storage for backup files.
https://altinity.com
Other
1.25k stars 225 forks source link

Error when selecting restored Nested datatype #306

Closed ctlaltdefeat closed 2 years ago

ctlaltdefeat commented 2 years ago

When restoring a table that includes a Nested datatype (which internally basically just creates subarrays I believe), the restoration "works" but I cannot select any of these column's values. I receive the following error:

Received exception from server (version 21.11.3):
Code: 32. DB::Exception: Received from localhost:9000. DB::Exception: Attempt to read after eof: (while reading column [nested_column].[nested_subcolumn]): (while reading from part /var/lib/clickhouse/store/913/913a8ede-fb7c-403f-913a-8edefb7cf03f/202110_91_91_15/ from mark 114367 with max_rows_to_read = 14914): While executing MergeTreeReverse. (ATTEMPT_TO_READ_AFTER_EOF)

where [nested_column] and [nested_subcolumn] are the names of the column and one of the "subcolumns".

All other columns work fine. I believe there is somewhat of a Clickhouse version mismatch between the instance from which the table was backup up and the restored instance, but that's not something that I can control right now.

I've also tried manually creating the schema with the Nested datatype exactly as I created the original table and restoring just the data, and I've also tried creating the schema with Array subcolumns instead of the Nested datatype and restoring the data, all lead to the same error.

Is there something else that I could try to access these columns?

Slach commented 2 years ago

Could you share table schema SQL file from /var/lib/clickhouse/backup/backup_name/metadata/db/table_name.sql? And also share clickhouse-server version on source server? It should to store on /var/lib/clickhouse/backup/backup_name/metadata.json

ctlaltdefeat commented 2 years ago

I was able to find the schema in the "query" field of /var/lib/clickhouse/backup/backup_name/metadata/db/table_name.json:

CREATE TABLE default.events 
(
`id` String, 
`timestamp` DateTime64(3), 
.... (working fields) ... ,
`nested_column1.nested_subcolumn1` Array(String), 
`nested_column1.nested_subcolumn2` Array(UInt16), 
`nested_column2.nested_subcolumn1` Array(String), 
`nested_column2.nested_subcolumn2` Array(UInt16) 
ENGINE = ReplacingMergeTree() PARTITION BY toYYYYMM(timestamp) ORDER BY (timestamp, id)

The clickhouse version on the source server is v20.4.2.9-stable. The version on target is 21.11.3.

ctlaltdefeat commented 2 years ago

Just as an update/correction, I'm also apparently having issue with a different column named features which is defined simply as Array(String). So it seems there's an issue with Arrays in general for me (there are no other Arrays/Nested types in the table)

Code: 271. DB::Exception: Received from localhost:9000. DB::Exception: Data compressed with different methods, given method byte 0x01, previous method byte 0x82: (while reading column features): (while reading from part /var/lib/clickhouse/store/5d2/5d2c1c3f-1711-4ce1-9d2c-1c3f17
110ce1/202109_85_85_21/ from mark 121856 with max_rows_to_read = 5824): While executing MergeTreeReverse. (CANNOT_DECOMPRESS)
Slach commented 2 years ago

@ctlaltdefeat please create separate issue for Data compressed with different methods

ctlaltdefeat commented 2 years ago

Thanks, did.

Slach commented 2 years ago

@ctlaltdefeat sorry for late response, look like issue is not related with clickhouse-backup itself, but related to clickhouse-server

Did you try to restore on newer version of clickhouse-server than backup created?

Slach commented 2 years ago

looks similar https://github.com/ClickHouse/ClickHouse/issues/34953

did you try to upgrade clickhouse-server to 22.3 ?