Skip to content

HIVE-26830: Update metastore-server image - #6825

Open
thomasrebele wants to merge 15 commits into
apache:masterfrom
thomasrebele:tr/HIVE-26830-v3
Open

thomasrebele wants to merge 15 commits into
apache:masterfrom
thomasrebele:tr/HIVE-26830-v3

Conversation

@thomasrebele

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Update hive-postgres-tpcds-metastore to use a TPC-DS 30TB dump with histogram column statistics. I've spent quite a lot of time to find a way to reduce the image size while keeping the performance of TestTezTPCDS30TBPerfCliDriver. I opted for compressing the raw database files from Postgres and setting some Postgres config options. See the scripts that I used to cleanup and generate the raw dump.

On my machine, TestTezTPCDS30TBPerfCliDriver using the proposed image runs in about 270s, while TestTezTPCDS30TBPerfCliDriver with the currently used image takes 350s, assuming the images have already been downloaded. So while the image with the histogram column statistics has a much larger database, the tests are executed faster. The download time is not taken into account, as here the image without the histogram statistics would clearly win.

Why are the changes needed?

The dump includes histogram statistics, making it possible to use them in future tests. (HIVE-26830).

Does this PR introduce any user-facing change?

No

How was this patch tested?

I build the image locally and executed TestTezTPCDS30TBPerfCliDriver. See the corresponding q.out file changes. See this comment for an explanation for the q.out file changes (the histograms are not yet used in the planning phase).

@thomasrebele

Copy link
Copy Markdown
Contributor Author

As far as I know, the changes of this PR do not affect the tests, so I cancelled continuous-integration/jenkins/pr-head.

@zabetak zabetak 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.

I tried to test the new image with TestTezTPCDS30TBPerfCliDriver but bumped into various errors. In order to make this PR more self-contained it would be nice to include all the necessary changes and have TestTezTPCDS30TBPerfCliDriver run with the new image. For the time being we don't need to switch to use histograms in the test.

The description mentions that tests are going to run faster when image is present but in the current state of the CI we are gonna fetch it everytime so we have to account for an extra 1GB of download overhead.

Comment on lines +21 to +22
A dockerized Postgres database with a Hive metastore dump from a
[TPC-DS 30TB dataset](https://github.com/zabetak/hive-test-datasets/releases/download/1.0/metastore_tpcds30tb_3_1_3000.dump.gz).
[TPC-DS 30TB dataset](https://github.com/thomasrebele/hive-postgres-metastore/releases/download/tpcds-30tb-histogram-1.0/metastore_tpcds30tb_with_histograms.raw_db.zstd), including histograms. The dump has been created with a fresh Postgres database, importing a dump with `pg_restore`, stopping Postgres, and then compressing the Postgres database files. More details can be found [here](https://github.com/thomasrebele/hive-postgres-metastore/tree/tpcds-30tb-histogram-1.0).

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.

Since now we have an official ASF repo for hosting datasets (https://github.com/apache/hive-test-datasets) please raise a PR there for adding the extra details and replace the link to point there.

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.

I guess we have to update the link since the dump that we use is now in https://nightlies.apache.org/. A pending question is where to put extra details and scripts to avoid linking to personal GitHub accounts but we could settle this later.

@thomasrebele thomasrebele left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thank you for the review, @zabetak! The new dump changes lots of the q.out files, so I thought updating the image first and then the test files would be appropriate. I'm fine with merging these two steps, but I think I don't have enough rights to upload the files to Apache's Docker hub. As long as the image has not been published, the CI won't be able to run.

I was wondering, whether to include the scripts that I used to generate the dump here. Wdyt?

@zabetak zabetak 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.

@thomasrebele For the first CI run you could use the image from your personal Dockerhub account. If everything comes green I can push the image manually to the Apache DockerHub account and retrigger CI.

I understand the intention of committing the .q.out files and other changes separately but by doing so we are creating a new image that will land untested and will be unused for a certain time. For this reason, I am leaning more towards a slightly more complex and complete PR that starts using the image immediately.

The scripts for creating the dump should reside in the same repo where the dump lives. Let's keep them there for the time being.

@thomasrebele

thomasrebele commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor Author

Thank you for the suggestions. I'll work on them. I had looked into the options for reducing the image size that you had mentioned. Option 2 for removing the entry point did not work for me.

Question before integrating the q.out file changes into the PR: it came to my mind that the schema migration script could be integrated into the raw DB dump, so that no initialization is necessary. Wdyt, @zabetak?

@zabetak

zabetak commented Oct 6, 2026

Copy link
Copy Markdown
Member

The option 2 was not so much for reducing the image size but mainly for skipping the custom entry point and the decompression logic during startup. Not sure if its better but shared it so you can pick whatever you feel best. I enriched the respective discussion with the exact commands and tools I used.

Indeed the schema migration script could be incorporated in the dump but then we may need different images and binary dump files for different versions (e.g., upstream vs downstream). Feel free to pick the option that suits best, I don't have a strong opinion which direction to go.

@thomasrebele

Copy link
Copy Markdown
Contributor Author

Thinking more about it, schema changes will require a schema migration script anyway, so integrating it now would only help for a little while.

I've updated the dump to fix the WAL issues, uploaded a new docker image, updated PostgresTPCDS, and regenerated the q.out files. I'll let the CI run.

@thomasrebele

Copy link
Copy Markdown
Contributor Author

There are two test failures (though the CI run seems to be incomplete, as it is marked "aborted"):

  • TestLlapZookeeperRegistryImpl had a StackOverflowError. The test passes locally, and I don't think it uses the TPC-DS metastore dump, so it seems to be a flaky failure.
  • TestHiveRelJsonSchemaReader checks the schema of TPCDS query 1, and fails because CHAR(16) c_customer_id turned into a VARCHAR(2147483647) c_customer_id. I'll need to do some debugging to understand the cause of this change.
TestHiveRelJsonSchemaReader stack trace

org.opentest4j.AssertionFailedError: expected: <RecordType(BIGINT c_customer_sk, CHAR(16) c_customer_id, BIGINT c_current_cdemo_sk, BIGINT c_current_hdemo_sk, BIGINT c_current_addr_sk, BIGINT c_first_shipto_date_sk, BIGINT c_first_sales_date_sk, CHAR(10) c_salutation, CHAR(20) c_first_name, CHAR(30) c_last_name, CHAR(1) c_preferred_cust_flag, INTEGER c_birth_day, INTEGER c_birth_month, INTEGER c_birth_year, VARCHAR(20) c_birth_country, CHAR(13) c_login, CHAR(50) c_email_address, BIGINT c_last_review_date_sk, BIGINT BLOCK__OFFSET__INSIDE__FILE, VARCHAR(2147483647) INPUT__FILE__NAME, RecordType(BIGINT writeid, INTEGER bucketid, BIGINT rowid) ROW__ID, BOOLEAN ROW__IS__DELETED)> but was: <RecordType(BIGINT c_customer_sk, VARCHAR(2147483647) c_customer_id, BIGINT c_current_cdemo_sk, BIGINT c_current_hdemo_sk, BIGINT c_current_addr_sk, BIGINT c_first_shipto_date_sk, BIGINT c_first_sales_date_sk, CHAR(10) c_salutation, CHAR(20) c_first_name, CHAR(30) c_last_name, CHAR(1) c_preferred_cust_flag, INTEGER c_birth_day, INTEGER c_birth_month, INTEGER c_birth_year, VARCHAR(20) c_birth_country, CHAR(13) c_login, CHAR(50) c_email_address, BIGINT c_last_review_date_sk, BIGINT BLOCK__OFFSET__INSIDE__FILE, VARCHAR(2147483647) INPUT__FILE__NAME, RecordType(BIGINT writeid, INTEGER bucketid, BIGINT rowid) ROW__ID, BOOLEAN ROW__IS__DELETED)>
	at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
	at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
	at org.junit.jupiter.api.AssertEquals.failNotEqual(AssertEquals.java:197)
	at org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:182)
	at org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:177)
	at org.junit.jupiter.api.Assertions.assertEquals(Assertions.java:1145)
	at org.apache.hadoop.hive.ql.optimizer.calcite.TestHiveRelJsonSchemaReader.testReadSchemaFromTpcdsQuery1(TestHiveRelJsonSchemaReader.java:55)

@thomasrebele

thomasrebele commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor Author

According to the TPC-DS specification (Table 2-14 on page 34), c_customer_id should have the type CHAR(16). It seems that the script to create the table for the new metastore dump used the type string instead:

> select DISTINCT t."TBL_NAME" AS table_name, c."COLUMN_NAME", c."TYPE_NAME" 
  FROM "DBS" d, "TBLS" t, "SDS" s, "COLUMNS_V2" c
  WHERE d."DB_ID" = t."DB_ID" and t."SD_ID" = s."SD_ID" and s."CD_ID" = c."CD_ID"
  and c."COLUMN_NAME" = 'c_customer_id';

 table_name |  COLUMN_NAME  | TYPE_NAME 
------------+---------------+-----------
 customer   | c_customer_id | string
(1 row)

This is the same for column ca_address_id, which also uses string instead of CHAR(16).

@zabetak, would it be ok to fix it in the PostgresTPCDS#install method, or is it required to update the database dump and container image?

@zabetak

zabetak commented Oct 7, 2026

Copy link
Copy Markdown
Member

Regarding the type discrepancy on c_customer_id and ca_address_id it may be fine to just update the test code if it affects just a single test.

If fixing the type accuracy can lead to less .q.out discrepancies then I guess its worth doing if its not complicated/risky (we don't want to end-up with a semi corrupted dump with internal inconsistencies).

@thomasrebele

Copy link
Copy Markdown
Contributor Author

I've stopped the CI to reduce infrastructure costs. I've updated the image docker.io/thomasrebele/postgres-tpcds-metastore:1.5 with the definition in 9c16680. If you're ok with the changes, @zabetak, I'm happy to run the CI (maybe after updating the docker image to the final URL?).

@zabetak

zabetak commented Oct 8, 2026

Copy link
Copy Markdown
Member

I build the image locally on commit 9c16680e8193d55b09ca87b5b1ceafe1e390029f and pushed it to https://hub.docker.com/layers/apache/hive-postgres-tpcds-metastore/1.5 so you can update the PR and run the CI with that one.

@sonarqubecloud

sonarqubecloud Bot commented Oct 9, 2026

Copy link
Copy Markdown

@thomasrebele

Copy link
Copy Markdown
Contributor Author

The CI got confused about the git history (fatal: refusing to merge unrelated histories). I suggest to rebase the PR before doing a final CI run.

@zabetak, I've removed the custom postgresql.conf. Would you update the docker.io/apache/hive-postgres-tpcds-metastore:1.5 image, please?

This branch has not been deployed

No deployments
Sign up for free to 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.

3 participants