jaiminpan / pg_jieba

Postgresql full-text search extension for chinese
BSD 3-Clause "New" or "Revised" License
338 stars 65 forks source link

pg 11.5 不支持 #42

Closed ssfdust closed 4 years ago

ssfdust commented 4 years ago

根据这篇文章 http://mysql.taobao.org/monthly/2018/04/10/ 做成了docker镜像, 镜像地址 https://github.com/ssfdust/psql_jieba_swsc

docker pull ssfdust/psql_jieba_swsc
docker run --name psql -e POSTGRES_PASSWORD=passwd -d ssfdust/psql_jieba_swsc

运行日志

The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /var/lib/postgresql/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default timezone ... Etc/UTC
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

    pg_ctl -D /var/lib/postgresql/data -l logfile start

waiting for server to start....2019-09-27 09:05:36.130 UTC [43] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2019-09-27 09:05:36.162 UTC [44] LOG:  database system was shut down at 2019-09-27 09:05:23 UTC
2019-09-27 09:05:36.173 UTC [43] LOG:  database system is ready to accept connections
 done
server started

/usr/local/bin/docker-entrypoint.sh: sourcing /docker-entrypoint-initdb.d/init-dict.sh

/usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/init-jieba.sql
2019-09-27 09:05:36.975 UTC [59] LOG:  pg_jieba Extension is not loaded by shared_preload_libraries, Variables can't be configured
2019-09-27 09:05:36.975 UTC [59] STATEMENT:  CREATE EXTENSION pg_jieba;
2019-09-27 09:05:40.973 UTC [43] LOG:  server process (PID 59) was terminated by signal 11: Segmentation fault
2019-09-27 09:05:40.973 UTC [43] DETAIL:  Failed process was running: CREATE EXTENSION pg_jieba;
2019-09-27 09:05:40.973 UTC [43] LOG:  terminating any other active server processes
psql:/docker-entrypoint-initdb.d/init-jieba.sql:1: server closed the connection unexpectedly
        This probably means the server terminated abnormally
        before or while processing the request.
psql:/docker-entrypoint-initdb.d/init-jieba.sql:1: connection to server was lost
2019-09-27 09:05:40.973 UTC [48] WARNING:  terminating connection because of crash of another server process
2019-09-27 09:05:40.973 UTC [48] DETAIL:  The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
2019-09-27 09:05:40.973 UTC [48] HINT:  In a moment you should be able to reconnect to the database and repeat your command.

看起来是服务端在处理pg_jieba的时候直接挂掉了,有什么解决方案吗?或者我下一步应该怎么做?

jaiminpan commented 4 years ago

看起来是没有配置shared_preload_libraries的关系。之前的有这个问题,不过后来修复了。所以需要先确定两个问题。1.不用docker的版本有没有问题。2.做成docker镜像的版本是不是最新的代码。

jaiminpan commented 4 years ago

和pg版本没有关系。pg11应该是支持的

ssfdust commented 4 years ago

谢谢回复

Docker的版本是

docker --version                         
Docker version 19.03.2-ce, build 6a30dfca03

代码是最新的代码,直接从github上拉取的,现在即时我在本地测试pg11.5也不能使用pg_jieba 插件。 CREATE EXTENSTION pg_jieba的时候报错。

Edit: 测试环境:Archlinux pg版本: 11.5 错误信息

postgres=# CREATE EXTENSION pg_jieba;
server closed the connection unexpectedly
        This probably means the server terminated abnormally
        before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.
!>
jaiminpan commented 4 years ago

使用 postgres commit 0baa55655e0549cf19fcfdb007c3250f7d4761a9 (HEAD -> REL_11_STABLE) pg_jieba commit 8995a41872415b489969ef9970517a613040ce28 (HEAD -> master) 测试了一下。

Screen Shot 2019-09-29 at 9 39 08 AM

本地测试了。。并没有发现问题。。你看下pg_jieba的commit 版本。

ssfdust commented 4 years ago

pg_jieba的commit 8995a41872415b489969ef9970517a613040ce28 (HEAD -> master, origin/master, origin/HEAD) README update 这个版本的,我前天刚刚拉的应该没问题把 image

ssfdust commented 4 years ago

日志

2019-09-30 09:10:37.561 CST [4139466] LOG:  pg_jieba Extension is not loaded by shared_preload_libraries, Variables can't be configured
2019-09-30 09:10:37.561 CST [4139466] STATEMENT:  CREATE EXTENSION pg_jieba;
2019-09-30 09:10:40.117 CST [4137296] LOG:  server process (PID 4139466) was terminated by signal 11: Segmentation fault
2019-09-30 09:10:40.117 CST [4137296] DETAIL:  Failed process was running: CREATE EXTENSION pg_jieba;
2019-09-30 09:10:40.117 CST [4137296] LOG:  terminating any other active server processes
2019-09-30 09:10:40.117 CST [4137302] WARNING:  terminating connection because of crash of another server process
2019-09-30 09:10:40.117 CST [4137302] DETAIL:  The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
2

有没有手动修复的方法?

oirontro commented 4 years ago

设了preload之后,

shared_preload_libraries = 'pg_jieba'   # (change requires restart)

还是不行:

2019-10-03 09:33:12.790 GMT [1] LOG:  database system is ready to accept connections
2019-10-03 09:33:53.411 GMT [1] LOG:  server process (PID 165) was terminated by signal 11: Segmentation fault
2019-10-03 09:33:53.411 GMT [1] DETAIL:  Failed process was running: create extension pg_jieba;
2019-10-03 09:33:53.411 GMT [1] LOG:  terminating any other active server processes
2019-10-03 09:33:53.411 GMT [153] WARNING:  terminating connection because of crash of another server process

Docker, Debian stretch:

$ uname -a
Linux 1509fad48310 4.15.0-62-generic #69-Ubuntu SMP Wed Sep 4 20:55:53 UTC 2019
x86_64 GNU/Linux
$ postgres --version
postgres (PostgreSQL) 11.5

如果能有个可以成功的 Dockerfile 就好了。

jaiminpan commented 4 years ago

fixed。 commit 2eb7cfe please update to new commit then try again Thanks for your reporting issue

ssfdust commented 4 years ago

@jaiminpan 谢谢。已确认可以正常工作,pg 12也测试通过。 @oirontro 我发布了下面这个docker,我这边测试是可以用的。 地址在这里: https://cloud.docker.com/repository/docker/ssfdust/psql_jieba_swsc/general 测试指令:

docker run --name testjieba -e POSTGRES_PASSWORD=passwd -e POSTGRES_USER=test -e POSTGRES_DB=testdb -d ssfdust/psql_jieba_swsc
docker exec -ti testjieba psql -U test testdb

截图: image

jaiminpan commented 4 years ago

@ssfdust 我把 你的docker file 放在 readme 里了。感谢