[BEAM-6627] Add size reporting to JdbcIOIT#10267
Conversation
|
R: @lgajowy wdyt? |
e8c6858 to
7e2c1f0
Compare
lgajowy
left a comment
There was a problem hiding this comment.
Suggested a different approach. Let me know what do you think. Thanks!
| statement.executeQuery(String.format("select pg_relation_size('%s')", tableName)); | ||
| if (resultSet.next()) { | ||
| return resultSet.getLong(1); | ||
| } else return 0L; |
There was a problem hiding this comment.
It looks that the code returns 0L in case the size is not available (am I right?) Maybe we shouldn't return 0L in that case - "else" means in this case that "we couldn't retrieve the size" not that it is equal to 0.
Have you considered using Optional here?
There was a problem hiding this comment.
You're right, that's a huge improvement. Thanks for the suggestion!
| DatabaseTestHelper.getPostgresTableSize(dataSource, tableName); | ||
| return NamedTestResult.create( | ||
| uuid, timestamp, "total_size", tableSizeAfterWrite - tableSize); | ||
| } catch (SQLException e) { |
There was a problem hiding this comment.
In this case optional could be useful too. The getPostgresTableSize could catch the error and return empty() in case of problems. Then, here, you could decide if to publish the metric or not, or even fail the whole test, depending on whether you have all the necessary metrics collected.
There was a problem hiding this comment.
You're right, I changed it
|
@lgajowy WDYT now? I changed the methods to use Optional - it really helped, thanks! |
|
Run Java JdbcIO Performance Test |
I added size checking to JdbcIOIT only for PostgreSQL because the test is based on this dialect and I don't think adding more makes sense.
Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
R: @username).[BEAM-XXX] Fixes bug in ApproximateQuantiles, where you replaceBEAM-XXXwith the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue.See the Contributor Guide for more tips on how to make review process smoother.
Post-Commit Tests Status (on master branch)
Pre-Commit Tests Status (on master branch)
See .test-infra/jenkins/README for trigger phrase, status and link of all Jenkins jobs.