Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Multi-Database Support][postgre] add postgre sql and docs #4782

Closed
wants to merge 6 commits into from

Conversation

shoothzj
Copy link
Member

@shoothzj shoothzj commented Mar 8, 2023

Brief changelog

Add postgre sql and docs

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

  • Read the Contributing Guide before making this pull request.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Write necessary unit tests to verify the code.
  • Run mvn clean test to make sure this pull request doesn't break anything.
  • Update the CHANGES log.

@codecov
Copy link

codecov bot commented Mar 8, 2023

Codecov Report

Merging #4782 (69ff653) into master (ee028dd) will increase coverage by 0.03%.
The diff coverage is n/a.

@@             Coverage Diff              @@
##             master    #4782      +/-   ##
============================================
+ Coverage     47.26%   47.29%   +0.03%     
+ Complexity     1661     1660       -1     
============================================
  Files           346      346              
  Lines         10683    10683              
  Branches       1063     1063              
============================================
+ Hits           5049     5053       +4     
+ Misses         5327     5322       -5     
- Partials        307      308       +1     

see 5 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

scripts/build.bat Outdated Show resolved Hide resolved
/* # CREATE apolloconfigdb; */
/* # ------------------------------------------------------------ */

CREATE DATABASE "ApolloPortalDB";
Copy link
Member

Choose a reason for hiding this comment

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

It looks like Postgres is very different from MySQL, which would make future contributions harder.
I'm thinking how about we abstract a storage layer this time and move the Postgres support to a new git repository, e.g. apollo-storage-extensions? The apollo-storage-extensions repository would target a specific version of apollo and doesn't have to be updated every time a feature is added. It would instead be updated by some Postgres user from time to time when they think is necessary.

cc @apolloconfig/committers what do you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

I humbly suggest that we create a separate folder for now, as we are not entirely clear on which boundaries should be placed between multiple databases in the main code and extensions. My recommendation is that we start by placing PostgreSQL and other databases in a separate folder. Once we have successfully achieved compatibility with one or two databases, we can then begin to separate the repository.
cc @apolloconfig/committers

@@ -248,3 +248,118 @@ Apollo Config Demo. Please input key to get the value. Input quit to exit.
app.id=你的appId
```
运行`./demo.sh client`启动Demo客户端即可。

Copy link
Member

Choose a reason for hiding this comment

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

what's the default database for quick start?

Copy link
Member Author

Choose a reason for hiding this comment

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

@nobodyiam I think it will be mysql, since we haven't finish h2 feature.

Copy link
Member

Choose a reason for hiding this comment

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

If mysql is the default, then section 5.2 is not necessary?

@shoothzj shoothzj force-pushed the postgre-support branch 2 times, most recently from 41c65a9 to 7d2227a Compare March 9, 2023 10:47
@nobodyiam
Copy link
Member

I'm not familiar with postgre but when I tried to import the sql files, some errors occurred:

psql (15.2)
Type "help" for help.

postgres=# 
postgres=# \i /your_local_path/sql/postgre/apollo_init_user.sql
CREATE DATABASE
You are now connected to database "ApolloConfigDB" as user "postgres".
CREATE SCHEMA
GRANT
GRANT
GRANT
GRANT
CREATE DATABASE
You are now connected to database "ApolloPortalDB" as user "postgres".
CREATE SCHEMA
GRANT
GRANT
GRANT
GRANT
ApolloPortalDB=# \i /your_local_path/sql/postgre/apolloportaldb.sql
You are now connected to database "ApolloPortalDB" as user "postgres".
psql:/your_local_path/sql/postgre/apolloportaldb.sql:22: ERROR:  syntax error at or near ""ApolloPortalDB""
LINE 1: "ApolloPortalDB"
        ^
CREATE TABLE
CREATE INDEX
CREATE INDEX
psql:/your_local_path/sql/postgre/apolloportaldb.sql:49: NOTICE:  table "AppNamespace" does not exist, skipping
DROP TABLE
CREATE TABLE
CREATE INDEX
CREATE INDEX
psql:/your_local_path/sql/postgre/apolloportaldb.sql:75: NOTICE:  table "Consumer" does not exist, skipping
DROP TABLE
CREATE TABLE
CREATE INDEX
psql:/your_local_path/sql/postgre/apolloportaldb.sql:101: NOTICE:  table "ConsumerAudit" does not exist, skipping
DROP TABLE
CREATE TABLE
CREATE INDEX
CREATE INDEX
psql:/your_local_path/sql/postgre/apolloportaldb.sql:121: NOTICE:  table "ConsumerRole" does not exist, skipping
DROP TABLE
CREATE TABLE
CREATE INDEX
CREATE INDEX
psql:/your_local_path/sql/postgre/apolloportaldb.sql:144: NOTICE:  table "ConsumerToken" does not exist, skipping
DROP TABLE
CREATE TABLE
CREATE INDEX
psql:/your_local_path/sql/postgre/apolloportaldb.sql:167: NOTICE:  table "Favorite" does not exist, skipping
DROP TABLE
CREATE TABLE
CREATE INDEX
CREATE INDEX
psql:/your_local_path/sql/postgre/apolloportaldb.sql:191: NOTICE:  table "Permission" does not exist, skipping
DROP TABLE
CREATE TABLE
CREATE INDEX
psql:/your_local_path/sql/postgre/apolloportaldb.sql:213: NOTICE:  table "Role" does not exist, skipping
DROP TABLE
CREATE TABLE
CREATE INDEX
psql:/your_local_path/sql/postgre/apolloportaldb.sql:234: NOTICE:  table "RolePermission" does not exist, skipping
DROP TABLE
CREATE TABLE
CREATE INDEX
CREATE INDEX
psql:/your_local_path/sql/postgre/apolloportaldb.sql:258: NOTICE:  table "ServerConfig" does not exist, skipping
DROP TABLE
CREATE TABLE
CREATE INDEX
psql:/your_local_path/sql/postgre/apolloportaldb.sql:281: NOTICE:  table "UserRole" does not exist, skipping
DROP TABLE
CREATE TABLE
CREATE INDEX
CREATE INDEX
psql:/your_local_path/sql/postgre/apolloportaldb.sql:304: NOTICE:  table "Users" does not exist, skipping
DROP TABLE
CREATE TABLE
psql:/your_local_path/sql/postgre/apolloportaldb.sql:322: NOTICE:  table "Authorities" does not exist, skipping
DROP TABLE
CREATE TABLE
INSERT 0 8
INSERT 0 1
INSERT 0 1
CREATE TABLE
CREATE INDEX
CREATE INDEX
CREATE INDEX
CREATE TABLE
ALTER TABLE
ApolloPortalDB=# \i /your_local_path/sql/postgre/apolloconfigdb.sql
You are now connected to database "ApolloPortalDB" as user "postgres".
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:21: ERROR:  syntax error at or near ""ApolloConfigDB""
LINE 1: "ApolloConfigDB"
        ^
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:40: ERROR:  schema "apolloconfig" does not exist
LINE 1: CREATE TABLE apolloconfig."App"
                     ^
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:42: ERROR:  schema "apolloconfig" does not exist
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:43: ERROR:  schema "apolloconfig" does not exist
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:48: NOTICE:  schema "apolloconfig" does not exist, skipping
DROP TABLE
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:66: ERROR:  schema "apolloconfig" does not exist
LINE 1: CREATE TABLE apolloconfig."AppNamespace"
                     ^
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:68: ERROR:  schema "apolloconfig" does not exist
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:69: ERROR:  schema "apolloconfig" does not exist
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:74: NOTICE:  schema "apolloconfig" does not exist, skipping
DROP TABLE
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:90: ERROR:  schema "apolloconfig" does not exist
LINE 1: CREATE TABLE apolloconfig."Audit"
                     ^
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:92: ERROR:  schema "apolloconfig" does not exist
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:97: NOTICE:  schema "apolloconfig" does not exist, skipping
DROP TABLE
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:113: ERROR:  schema "apolloconfig" does not exist
LINE 1: CREATE TABLE apolloconfig."Cluster"
                     ^
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:115: ERROR:  schema "apolloconfig" does not exist
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:116: ERROR:  schema "apolloconfig" does not exist
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:121: NOTICE:  schema "apolloconfig" does not exist, skipping
DROP TABLE
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:138: ERROR:  schema "apolloconfig" does not exist
LINE 1: CREATE TABLE apolloconfig."Commit"
                     ^
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:140: ERROR:  schema "apolloconfig" does not exist
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:141: ERROR:  schema "apolloconfig" does not exist
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:142: ERROR:  schema "apolloconfig" does not exist
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:143: ERROR:  schema "apolloconfig" does not exist
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:148: NOTICE:  schema "apolloconfig" does not exist, skipping
DROP TABLE
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:167: ERROR:  schema "apolloconfig" does not exist
LINE 1: CREATE TABLE apolloconfig."GrayReleaseRule"
                     ^
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:169: ERROR:  schema "apolloconfig" does not exist
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:170: ERROR:  schema "apolloconfig" does not exist
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:175: NOTICE:  schema "apolloconfig" does not exist, skipping
DROP TABLE
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:188: ERROR:  schema "apolloconfig" does not exist
LINE 1: CREATE TABLE apolloconfig."Instance"
                     ^
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:190: ERROR:  schema "apolloconfig" does not exist
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:191: ERROR:  schema "apolloconfig" does not exist
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:196: NOTICE:  schema "apolloconfig" does not exist, skipping
DROP TABLE
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:211: ERROR:  schema "apolloconfig" does not exist
LINE 1: CREATE TABLE apolloconfig."InstanceConfig"
                     ^
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:213: ERROR:  schema "apolloconfig" does not exist
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:214: ERROR:  schema "apolloconfig" does not exist
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:217: ERROR:  schema "apolloconfig" does not exist
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:222: NOTICE:  schema "apolloconfig" does not exist, skipping
DROP TABLE
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:240: ERROR:  schema "apolloconfig" does not exist
LINE 1: CREATE TABLE apolloconfig."Item"
                     ^
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:242: ERROR:  schema "apolloconfig" does not exist
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:243: ERROR:  schema "apolloconfig" does not exist
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:248: NOTICE:  schema "apolloconfig" does not exist, skipping
DROP TABLE
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:264: ERROR:  schema "apolloconfig" does not exist
LINE 1: CREATE TABLE apolloconfig."Namespace"
                     ^
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:266: ERROR:  schema "apolloconfig" does not exist
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:267: ERROR:  schema "apolloconfig" does not exist
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:272: NOTICE:  schema "apolloconfig" does not exist, skipping
DROP TABLE
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:286: ERROR:  schema "apolloconfig" does not exist
LINE 1: CREATE TABLE apolloconfig."NamespaceLock"
                     ^
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:288: ERROR:  schema "apolloconfig" does not exist
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:293: NOTICE:  schema "apolloconfig" does not exist, skipping
DROP TABLE
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:314: ERROR:  schema "apolloconfig" does not exist
LINE 1: CREATE TABLE apolloconfig."Release"
                     ^
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:316: ERROR:  schema "apolloconfig" does not exist
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:317: ERROR:  schema "apolloconfig" does not exist
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:324: NOTICE:  schema "apolloconfig" does not exist, skipping
DROP TABLE
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:344: ERROR:  schema "apolloconfig" does not exist
LINE 1: CREATE TABLE apolloconfig."ReleaseHistory"
                     ^
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:346: ERROR:  schema "apolloconfig" does not exist
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:347: ERROR:  schema "apolloconfig" does not exist
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:348: ERROR:  schema "apolloconfig" does not exist
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:349: ERROR:  schema "apolloconfig" does not exist
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:354: NOTICE:  schema "apolloconfig" does not exist, skipping
DROP TABLE
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:362: ERROR:  schema "apolloconfig" does not exist
LINE 1: CREATE TABLE apolloconfig."ReleaseMessage"
                     ^
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:364: ERROR:  schema "apolloconfig" does not exist
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:365: ERROR:  schema "apolloconfig" does not exist
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:370: NOTICE:  schema "apolloconfig" does not exist, skipping
DROP TABLE
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:387: ERROR:  schema "apolloconfig" does not exist
LINE 1: CREATE TABLE apolloconfig."ServerConfig"
                     ^
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:389: ERROR:  schema "apolloconfig" does not exist
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:394: NOTICE:  schema "apolloconfig" does not exist, skipping
DROP TABLE
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:410: ERROR:  schema "apolloconfig" does not exist
LINE 1: CREATE TABLE apolloconfig."AccessKey"
                     ^
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:412: ERROR:  schema "apolloconfig" does not exist
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:417: NOTICE:  schema "apolloconfig" does not exist, skipping
DROP TABLE
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:430: ERROR:  schema "apolloconfig" does not exist
LINE 1: CREATE TABLE apolloconfig."ServiceRegistry"
                     ^
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:432: ERROR:  schema "apolloconfig" does not exist
psql:/your_local_path/sql/postgre/apolloconfigdb.sql:443: ERROR:  relation "apolloconfig.ServerConfig" does not exist
LINE 3: INSERT INTO apolloconfig."ServerConfig" ("Key", "Cluster", "...
                    ^
ApolloPortalDB=# 

docs/zh/deployment/quick-start.md Outdated Show resolved Hide resolved
|-------------|---------|-------|--------------------|
| 1 | timeout | 100 | sample timeout配置 |

## 5.3 配置其他数据库连接信息
Copy link
Member

Choose a reason for hiding this comment

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

We need to list detailed instructions to guide the users on how the change the demo.sh, e.g. how to change the spring_profiles_group_github.

Copy link
Member Author

Choose a reason for hiding this comment

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

@nobodyiam PTAL again.

Copy link
Member

Choose a reason for hiding this comment

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

This is the instructions to enable postgre, so it's better to merge it to 5.1

docs/zh/deployment/quick-start.md Outdated Show resolved Hide resolved
@shoothzj shoothzj force-pushed the postgre-support branch 2 times, most recently from 52a1d7f to 0703020 Compare March 10, 2023 02:15
docs/zh/deployment/quick-start.md Outdated Show resolved Hide resolved
docs/zh/deployment/quick-start.md Outdated Show resolved Hide resolved
docs/zh/deployment/quick-start.md Outdated Show resolved Hide resolved
docs/zh/deployment/quick-start.md Outdated Show resolved Hide resolved
docs/zh/deployment/quick-start.md Outdated Show resolved Hide resolved
docs/zh/deployment/quick-start.md Outdated Show resolved Hide resolved
docs/zh/deployment/quick-start.md Outdated Show resolved Hide resolved
|-------------|---------|-------|--------------------|
| 1 | timeout | 100 | sample timeout配置 |

## 5.3 配置其他数据库连接信息
Copy link
Member

Choose a reason for hiding this comment

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

This is the instructions to enable postgre, so it's better to merge it to 5.1


```

## 5.4 配置mysql数据库连接信息
Copy link
Member

Choose a reason for hiding this comment

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

This is the instructions to enable mysql, so it's better to merge it to 5.2

Copy link
Member Author

Choose a reason for hiding this comment

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

@nobodyiam fixed

docs/zh/deployment/quick-start.md Outdated Show resolved Hide resolved
@nobodyiam
Copy link
Member

BTW, apollo could start with pg now, but the following errors occurred when I tried to log in.
It's better to verify the major features before submitting them to the community for review.

2023-03-11 10:02:21.093 ERROR 72406 --- [nio-8070-exec-4] w.a.UsernamePasswordAuthenticationFilter : An internal error occurred while trying to authenticate the user.

org.springframework.security.authentication.InternalAuthenticationServiceException: PreparedStatementCallback; bad SQL grammar [select Username,Password,Enabled from `Users` where Username = ?]; nested exception is org.postgresql.util.PSQLException: ERROR: syntax error at or near "`"
  Position: 39
	at org.springframework.security.authentication.dao.DaoAuthenticationProvider.retrieveUser(DaoAuthenticationProvider.java:109)
	at org.springframework.security.authentication.dao.AbstractUserDetailsAuthenticationProvider.authenticate(AbstractUserDetailsAuthenticationProvider.java:133)
	at org.springframework.security.authentication.ProviderManager.authenticate(ProviderManager.java:182)
	at org.springframework.security.authentication.ProviderManager.authenticate(ProviderManager.java:201)
	at org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter.attemptAuthentication(UsernamePasswordAuthenticationFilter.java:85)
	at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:227)
	at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:217)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
	at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:103)
	at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:89)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
	at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:90)
	at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:75)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
	at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:112)
	at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:82)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
	at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:55)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
	at org.springframework.security.web.session.DisableEncodeUrlFilter.doFilterInternal(DisableEncodeUrlFilter.java:42)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
	at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:221)
	at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:186)
	at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:354)
	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:267)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at org.springframework.session.web.http.SessionRepositoryFilter.doFilterInternal(SessionRepositoryFilter.java:142)
	at org.springframework.session.web.http.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:82)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:96)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:102)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:177)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:891)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1784)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
	at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [select Username,Password,Enabled from `Users` where Username = ?]; nested exception is org.postgresql.util.PSQLException: ERROR: syntax error at or near "`"
  Position: 39
	at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:239)
	at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:70)
	at org.springframework.jdbc.core.JdbcTemplate.translateException(JdbcTemplate.java:1541)
	at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:667)
	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:713)
	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:744)
	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:757)
	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:815)
	at org.springframework.security.provisioning.JdbcUserDetailsManager.loadUsersByUsername(JdbcUserDetailsManager.java:177)
	at org.springframework.security.core.userdetails.jdbc.JdbcDaoImpl.loadUserByUsername(JdbcDaoImpl.java:184)
	at org.springframework.security.authentication.dao.DaoAuthenticationProvider.retrieveUser(DaoAuthenticationProvider.java:94)
	... 68 common frames omitted
Caused by: org.postgresql.util.PSQLException: ERROR: syntax error at or near "`"
  Position: 39
	at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2676)
	at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2366)
	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:356)
	at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:496)
	at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:413)
	at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:190)
	at org.postgresql.jdbc.PgPreparedStatement.executeQuery(PgPreparedStatement.java:134)
	at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeQuery(ProxyPreparedStatement.java:52)
	at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeQuery(HikariProxyPreparedStatement.java)
	at org.springframework.jdbc.core.JdbcTemplate$1.doInPreparedStatement(JdbcTemplate.java:722)
	at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:651)
	... 75 common frames omitted

shoothzj and others added 5 commits March 11, 2023 10:53
Copy link
Member

@nobodyiam nobodyiam left a comment

Choose a reason for hiding this comment

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

Looks like the pg sql is quite different from the mysql one, maybe it's better to put it in another repository for easier maintanance, e.g. apollo-storage-postgre

scripts/sql/postgre/apolloconfigdb.sql Outdated Show resolved Hide resolved
VALUES ('apollo', 'ROLE_user');

-- spring session (https://github.com/spring-projects/spring-session/blob/main/spring-session-jdbc/src/main/resources/org/springframework/session/jdbc/schema-postgresql.sql)
CREATE TABLE apolloportal.SPRING_SESSION
Copy link
Member

Choose a reason for hiding this comment

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

Is it better to quote the table name just like we did for other tables?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's copied from spring-session repo. I suggest we not change this. And spring-session connect to lower-case table.

CREATE INDEX SPRING_SESSION_IX2 ON apolloportal.SPRING_SESSION (EXPIRY_TIME);
CREATE INDEX SPRING_SESSION_IX3 ON apolloportal.SPRING_SESSION (PRINCIPAL_NAME);

CREATE TABLE apolloportal.SPRING_SESSION_ATTRIBUTES
Copy link
Member

Choose a reason for hiding this comment

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

Is it better to quote the table name just like we did for other tables?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's copied from spring-session repo. I suggest we not change this. And spring-session connect to lower-case table.

Co-authored-by: Jason Song <nobodyiam@gmail.com>
@shoothzj
Copy link
Member Author

Looks like the pg sql is quite different from the mysql one, maybe it's better to put it in another repository for easier maintanance, e.g. apollo-storage-postgre

Are we considering put these jpa sql in one repo. Like apollo-storage-rds?

@nobodyiam
Copy link
Member

Are we considering put these jpa sql in one repo. Like apollo-storage-rds?

Yes, I'm seriously considering creating a new repo to host schema/codes for different storages.
The basic idea is to keep the common logic in the main repo so that it's stable and easy to maintain. The MySQL support will also be in the main repo as it's the default storage mechanism and is widely used.
For other storage support, it's preferable to use the same code base in the main repo. However, if it does need some different DAO logic or schemas, then we could put it in the new repo and reference them when users enable the storage mode. It may not always support the latest version of apollo but I think it's ok as long as we document the specific version the storage supports. The community members could contribute to it to support the latest version of apollo when they think is necessary.

@stale
Copy link

stale bot commented Apr 17, 2023

This pull request has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 14 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@stale stale bot added the stale label Apr 17, 2023
@stale
Copy link

stale bot commented May 2, 2023

This pull request has been automatically closed because it has not had activity in the last 14 days. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@stale stale bot closed this May 2, 2023
@github-actions github-actions bot locked and limited conversation to collaborators May 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants