在 FreeSWITCH 1.8 上尝试通过 "pgsql" DSN returns "ERR [unable to open database file]" 连接到 PostgreSQL 数据库

Trying to connect to a PostgreSQL DB via "pgsql" DSN returns "ERR [unable to open database file]" on FreeSWITCH 1.8

当我尝试连接到远程 PostgreSQL 服务器时,我得到

2019-08-23[ERR] switch_core_db.c:223 SQL ERR [unable to open database file]

当使用带有 pgsql 连接字符串的 FreeSWITCH Lua API 时:

conn_string =
  "pgsql://hostaddr=1.2.3.4"                 ..
  " dbname=my-db"                            ..
  " user=postgres"                           ..
  " password=postgres"                       ..
  " options='-c client_min_messages=NOTICE'" ..
  " application_name='freeswitch'"

freeswitch.Dbh(conn_string)

(在docs中推荐)

此设置一直运行完美,即使在 FreeSWITCH 服务重新启动时也是如此, 然后我愚蠢地在 Debian 9 上做了一个 sudo apt update && sudo apt upgrade, 就是这样。

在我最后的挫折中,我使用新的 FreeSWITCH 安装重新创建整个 VM,并在 Debian 9 Stretch install guide:

中找到了一个新部分

1.10 incompatible change

because now Fs1.10 packages are installed even if you still use the 1.8 repo, you better aware of an incompatible change:

pgsql is no more in core, but in aptly named mod_pgsql.

You MUST NOT load mod_pgsql in modules.conf.xml (do not work), but in a special additional xml file, in same "autoload_configs" directory.

Filename: pre_load_modules.conf.xml

<configuration name="pre_load_modules.conf" description="Modules">
  <modules>
    <!-- Databases -->
    <!-- <load module="mod_mariadb"/> -->
    <load module="mod_pgsql"/>
  </modules>
</configuration>

所以当我做 sudo apt upgrade 时,FreeSWITCH 从 1.8 升级到 1.10。


(2019/08/23) 更新:更新pre_load_modules.conf.xml 无效,尽管有上述警告。它仅在将 mod_pgsql 添加到 modules.conf.xml 后连接。

Debian 9 Stretch 上的完整解决方案:

  1. <load module="mod_pgsql"/> 添加到 modules.conf.xml
  2. sudo systemctl stop freeswitch
  3. sudo systemctl start freeswitch

(2019/09/03) 更新和警告,来自 SignalWire 平台工程师 Andrey Volk

Andrey Volk:“除非您知道自己在做什么,否则不要将 mod_pgsql 添加到 modules.conf.xml。使用 pre_load_modules.conf.xml。如果有任何问题,请创建 Jira 票证。"

toraritte:“为什么在 module.conf.xml 中加载 mod_pgsql 会是个问题?

Andrey Volk:“不同之处在于核心可能也想使用该数据库。但它是核心,它在任何模块之前加载。所以我们需要一个特殊的地方,在任何其他模块类型之前加载数据库模块(以防万一其中一个用于核心)。另一方面,如果该数据库模块不被使用,使用什么文件并不重要核心。它应该先走。如果是 LUA,请在 LUA 之前加载它。但我们不会 recommend/document 那个。

如果无法识别 pre_load_modules.conf.xml,则可能是升级不当的结果。确保所有 freeswitch 包都已升级(包括主要包)。"