hashgraph / hedera-mirror-node

Hedera Mirror Node archives data from consensus nodes and serves it via an API
Apache License 2.0
117 stars 110 forks source link

Optimize topic message lookup migration #8631

Closed xin-hedera closed 5 days ago

xin-hedera commented 6 days ago

Description:

This PR optimizes the topic message lookup migration.

Related issue(s):

Fixes #8512

Notes for reviewer:

The previous optimized version with a fixed 12 top topics from mainnet db took about 52 minutes to complete.

The enhanced version in this PR is supposed to take less time, however I just ran it for the last several partitions:

2024-06-24T20:43:52.415Z  INFO main c.h.m.i.m.TopicMessageLookupMigration Migrated topic_message_lookup with 10159 rows for partition topic_message_p2024_06 in 22.56 s
2024-06-24T20:43:52.485Z  INFO single-1 c.h.m.i.m.TopicMessageLookupMigration Starting asynchronous migration
2024-06-24T20:43:52.485Z  INFO main c.h.m.i.m.TopicMessageLookupMigration Ran migration Backfill topic_message_lookup table in 28.17 s.
2024-06-24T20:44:31.221Z  INFO single-1 c.h.m.i.m.TopicMessageLookupMigration Migrated topic_message_lookup with 15408 rows for partition topic_message_p2024_05 in 37.15 s
2024-06-24T20:44:58.636Z  INFO single-1 c.h.m.i.m.TopicMessageLookupMigration Migrated topic_message_lookup with 34514 rows for partition topic_message_p2024_04 in 27.38 s
2024-06-24T20:44:58.677Z  INFO single-1 c.h.m.i.m.TopicMessageLookupMigration Completed iteration 2 with last value: topic_message_p2024_03
2024-06-24T20:45:43.501Z  INFO single-1 c.h.m.i.m.TopicMessageLookupMigration Migrated topic_message_lookup with 67023 rows for partition topic_message_p2024_03 in 44.82 s
2024-06-24T20:46:47.627Z  INFO single-1 c.h.m.i.m.TopicMessageLookupMigration Migrated topic_message_lookup with 4825 rows for partition topic_message_p2024_02 in 1.068 min
2024-06-24T20:46:47.668Z  INFO single-1 c.h.m.i.m.TopicMessageLookupMigration Completed iteration 4 with last value: topic_message_p2024_01
2024-06-24T20:47:43.565Z  INFO single-1 c.h.m.i.m.TopicMessageLookupMigration Migrated topic_message_lookup with 2846 rows for partition topic_message_p2024_01 in 55.90 s
2024-06-24T20:47:43.602Z  INFO single-1 c.h.m.i.m.TopicMessageLookupMigration Completed iteration 5 with last value: topic_message_p2023_12
2024-06-24T20:48:39.752Z  INFO single-1 c.h.m.i.m.TopicMessageLookupMigration Migrated topic_message_lookup with 1122 rows for partition topic_message_p2023_12 in 56.15 s
2024-06-24T20:48:39.792Z  INFO single-1 c.h.m.i.m.TopicMessageLookupMigration Completed iteration 6 with last value: topic_message_p2023_11

Checklist

codecov[bot] commented 6 days ago

Codecov Report

Attention: Patch coverage is 0% with 63 lines in your changes missing coverage. Please review.

Project coverage is 92.06%. Comparing base (ce4f947) to head (6c74f05). Report is 5 commits behind head on main.

Files Patch % Lines
...mporter/migration/TopicMessageLookupMigration.java 0.00% 63 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #8631 +/- ## ============================================ - Coverage 92.39% 92.06% -0.33% + Complexity 7489 7470 -19 ============================================ Files 914 914 Lines 29854 29914 +60 Branches 3640 3652 +12 ============================================ - Hits 27584 27541 -43 - Misses 1444 1547 +103 Partials 826 826 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

sonarcloud[bot] commented 6 days ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud