apolloconfig / apollo

Apollo is a reliable configuration management system suitable for microservice configuration management scenarios.
https://www.apolloconfig.com
Apache License 2.0
28.95k stars 10.19k forks source link

apollo assembly optimization #5035

Closed vdiskg closed 5 months ago

vdiskg commented 7 months ago

What's the purpose of this PR

  1. Assembly Portal, Config Service, Admin Service into a standalone process
  2. Assembly ApolloConfigDB, ApolloPortalDB into a single db.

Which issue(s) this PR fixes:

4313

4729

Brief changelog

  1. add table name prefix in the assembly sql
  2. add TablePrefixNamingStrategy to match the table name prefix

Follow this checklist to help us incorporate your contribution quickly and easily:

codecov[bot] commented 7 months ago

Codecov Report

Attention: 240 lines in your changes are missing coverage. Please review.

Comparison is base (921af84) 49.65% compared to head (e8b44ee) 50.38%.

Files Patch % Lines
...lloDataSourceScriptDatabaseInitializerFactory.java 0.00% 75 Missing :warning:
...lo/build/sql/converter/ApolloSqlConverterUtil.java 77.72% 35 Missing and 12 partials :warning:
.../datasource/ApolloSqlInitializationProperties.java 0.00% 32 Missing :warning:
...rce/ApolloDataSourceScriptDatabaseInitializer.java 0.00% 25 Missing :warning:
...ework/apollo/build/sql/converter/SqlStatement.java 55.55% 10 Missing and 2 partials :warning:
...llo/build/sql/converter/ApolloH2ConverterUtil.java 91.52% 6 Missing and 4 partials :warning:
...apollo/build/sql/converter/ApolloSqlConverter.java 86.36% 9 Missing :warning:
...apollo/build/sql/converter/SqlTemplateContext.java 62.50% 6 Missing :warning:
...rk/apollo/build/sql/converter/SqlTemplateGist.java 82.35% 6 Missing :warning:
...sql/converter/ApolloMysqlDefaultConverterUtil.java 78.26% 4 Missing and 1 partial :warning:
... and 7 more
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #5035 +/- ## ============================================ + Coverage 49.65% 50.38% +0.72% - Complexity 1908 2012 +104 ============================================ Files 372 387 +15 Lines 11564 12213 +649 Branches 1127 1207 +80 ============================================ + Hits 5742 6153 +411 - Misses 5479 5697 +218 - Partials 343 363 +20 ```

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

nobodyiam commented 7 months ago

Wow! This pr is truly thrilling!

nobodyiam commented 6 months ago

It appears there is some incompatibility with database-discovery. When I execute the assembly using the spring profiles github,auth,database-discovery, only the apollo-configservice gets registered.

image

nobodyiam commented 6 months ago

This is very impressive! I really like the click-and-go experience to start the apollo service with no extra setup.

Below are some comments for your review:

  1. Please update the pull request with the latest master branch, as there have been updates to the SQL files.
  2. Regarding the quick start guide, my preference is to continue using demo.sh for starting/stopping the services. However, we can address this in a separate pull request since it involves modifications to demo.sh itself.
  3. Some errors were encountered while using the assembly service.
    • Cancel favorite app image
Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "Favorite" not found; SQL statement:
Update Favorite set IsDeleted = true, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000) where Id = ? [42102-214]
Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "InstanceConfig" not found; SQL statement:
select b.Id from InstanceConfig a inner join Instance b on b.Id = a.`InstanceId` where a.`ConfigAppId` = ? and a.`ConfigClusterName` = ? and a.`ConfigNamespaceName` = ? and a.`DataChange_LastTime` > ? and b.`AppId` = ? limit ? [42102-214]

image

Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "GrayReleaseRule" not found; SQL statement:
Update GrayReleaseRule set IsDeleted = true, DeletedAt = ROUND(UNIX_TIMESTAMP(NOW(4))*1000) where Id = ? [42102-214]
nobodyiam commented 6 months ago

I'm considering the possibility of connecting our assembly application to two separate databases. This approach could simplify a lot by eliminating the need to rename table names. It involves establishing two distinct data sources, as outlined in this guide on Spring Data JPA with Multiple Databases.

nobodyiam commented 5 months ago

This pull request appears to be in good shape now. Could you also update the CHANGES.md file? Since this constitutes a major change, it's important to document it there.

nobodyiam commented 5 months ago

BTW, #5072 was merged with a schema change, would you please help to update the code base again?