gpt4 book ai didi

postgresql - 使用 Aerogear Unified Post Server + Docker + Postgres 获取 "ERROR: relation PRIMARY already exists"

转载 作者:行者123 更新时间:2023-11-29 12:24:49 25 4
gpt4 key购买 nike

我正在尝试使用 (1.2.0.Latest) Aerogear Unified Push Server (UPS) 的最新发行版的 dockerized 版本,但使用的是 Postgres 而不是 MySql。事实上,官方的 UPS Docker 发行版就是基于它的。更换底座中的连接器非常容易 Docker带有 Postgres 连接器的文件:

ENV POSTGRES_JDBC_VERSION 42.1.4
ENV db_module_dir=$JBOSS_HOME/modules/org/postgresql/main/
RUN mkdir -p ${db_module_dir}
RUN wget -O postgres-jdbc.jar http://central.maven.org/maven2/org/postgresql/postgresql/$POSTGRES_JDBC_VERSION/postgresql-$POSTGRES_JDBC_VERSION.jar
RUN mv postgres-jdbc.jar ${db_module_dir}
COPY configuration/xml/postgres-module.xml ${db_module_dir}/module.xml

我在旧版本中做了这个变体,一切正常。

现在,从头开始(通过 Docker Compose)启动容器(没有预先存在的数据库),我从构建/迁移数据库架构/数据的 Liquibase 作业 (jar) 中得到以下错误:

Unexpected error running Liquibase: org.postgresql.util.PSQLException: ERROR: relation "PRIMARY" already exists

这是完整的日志:

myproject_ups_db | The files belonging to this database system will be owned by user "postgres".
myproject_ups_db | This user must also own the server process.
myproject_ups_db |
myproject_ups_db | The database cluster will be initialized with locale "en_US.utf8".
myproject_ups_db | The default database encoding has accordingly been set to "UTF8".
myproject_ups_db | The default text search configuration will be set to "english".
myproject_ups_db |
myproject_ups_db | Data page checksums are disabled.
myproject_ups_db |
myproject_ups_db | fixing permissions on existing directory /var/lib/postgresql/data ... ok
myproject_ups_db | creating subdirectories ... ok
myproject_ups_db | selecting default max_connections ... 100
myproject_ups_db | selecting default shared_buffers ... 128MB
myproject_ups_db | selecting dynamic shared memory implementation ... posix
myproject_ups_db | creating configuration files ... ok
myproject_ups_db | creating template1 database in /var/lib/postgresql/data/base/1 ... ok
myproject_ups_db | initializing pg_authid ... ok
myproject_ups_db | initializing dependencies ... ok
myproject_ups_db | creating system views ... ok
myproject_ups_db | loading system objects' descriptions ... ok
myproject_ups_db | creating collations ... ok
myproject_ups_db | creating conversions ... ok
myproject_ups_db | creating dictionaries ... ok
myproject_ups_db | setting privileges on built-in objects ... ok
myproject_ups_db | creating information schema ... ok
myproject_ups_db | loading PL/pgSQL server-side language ... ok
myproject_ups_db | vacuuming database template1 ... ok
myproject_ups_db | copying template1 to template0 ... ok
myproject_ups_db | copying template1 to postgres ... ok
myproject_ups_db | syncing data to disk ... ok
myproject_ups_db |
myproject_ups_db | Success. You can now start the database server using:
myproject_ups_db |
myproject_ups_db | postgres -D /var/lib/postgresql/data
myproject_ups_db | or
myproject_ups_db | pg_ctl -D /var/lib/postgresql/data -l logfile start
myproject_ups_db |
myproject_ups_db |
myproject_ups_db | WARNING: enabling "trust" authentication for local connections
myproject_ups_db | You can change this by editing pg_hba.conf or using the option -A, or
myproject_ups_db | --auth-local and --auth-host, the next time you run initdb.
myproject_ups_db | waiting for server to start....LOG: database system was shut down at 2017-09-23 16:00:34 UTC
myproject_ups_db | LOG: MultiXact member wraparound protections are now enabled
myproject_ups_db | LOG: database system is ready to accept connections
myproject_ups_db | LOG: autovacuum launcher started
myproject_ups_db | done
myproject_ups_db | server started
myproject_ups_db | CREATE DATABASE
myproject_ups_db |
myproject_ups_db | CREATE ROLE
myproject_ups_db |
myproject_ups_db |
myproject_ups_db | /docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/
myproject_ups_db |
myproject_ups_db | LOG: received fast shutdown request
myproject_ups_db | LOG: aborting any active transactions
myproject_ups_db | LOG: autovacuum launcher shutting down
myproject_ups_db | LOG: shutting down
myproject_ups_db | waiting for server to shut down....LOG: database system is shut down
myproject_ups_db | done
myproject_ups_db | server stopped
myproject_ups_db |
myproject_ups_db | PostgreSQL init process complete; ready for start up.
myproject_ups_db |
myproject_ups_db | LOG: database system was shut down at 2017-09-23 16:00:36 UTC
myproject_ups_db | LOG: MultiXact member wraparound protections are now enabled
myproject_ups_db | LOG: database system is ready to accept connections
myproject_ups_db | LOG: autovacuum launcher started
myproject_ups | Starting Liquibase migration
myproject_ups | Unexpected error running Liquibase: org.postgresql.util.PSQLException: ERROR: relation "PRIMARY" already exists
myproject_ups |
myproject_ups |
myproject_ups exited with code 255

有什么建议吗?

最佳答案

终于,我找到了解决方案。我想在下面分享。

问题来自 Liquibase 作业 (jar) 中包含的最新文件:

liquibase/1.2.0/2017-09-06-flat-model-entities.xml

只是注释指令:

<changeSet author="matzew (generated)" id="1504688114371-22">
<addPrimaryKey columnNames="push_message_variant_id" constraintName="PRIMARY" tableName="variant_error_status"/>
</changeSet>

修复了“错误:关系“PRIMARY”已经存在”的问题。

之后还有两个处理索引“重复索引名”的问题:

  • app_open_counter,
  • 提交日期,

在上面的同一个文件中,只需将它们重命名为

  • idx_app_open_counter,
  • idx_submit_date,

使一切正常工作,没有错误。

我猜这些错误与使用 Postgres 有关,也许 Liquibase 作业是专门为 MySql 设计(和测试)的。

关于postgresql - 使用 Aerogear Unified Post Server + Docker + Postgres 获取 "ERROR: relation PRIMARY already exists",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46382453/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com