laurenz / oracle_fdw

PostgreSQL Foreign Data Wrapper for Oracle
http://laurenz.github.io/oracle_fdw/
Other
496 stars 156 forks source link

Incompatible library - magic block mismatch. Server has NAMEDATALEN=64, library has 256 #631

Closed Germes1 closed 11 months ago

Germes1 commented 11 months ago

Hi, I have 2 servers with Debian 10 , Postgresql 11 with replication. I installed oracle client, oracle_fdw(make from sources) on both servers. Master works without problem, but replica shows error when try select data from foreign server "Incompatible library /usr/lib/postgresql/11/lib/oracle_fdw.so magic block mismatch. Server has NAMEDATALEN=64, library has 256". Oracle_fdw files has different sizes on servers, I replaced it on replica from master, and it works. How can I make oracle_fdw with NAMEDATALEN=64?

laurenz commented 11 months ago

You are trying to use a library that was built against a PostgreSQL where NAMEDATALEN was modified. That won't work. Simply build oracle_fdw with the PostgreSQL installation where you are using it.

You can copy the library to another system if that other system is using the same operating system, the same PostgreSQL version and the same configuration of PostgreSQL.

Germes1 commented 11 months ago

Simply build oracle_fdw with the PostgreSQL installation where you are using it.

I did it, built from source, equal actions on both servers. Oracle_fdw.so has different file sizes, 650768 bytes on replica, and 648504 bytes on master. So, it's Postgresql installation problem. Where oracle_fdw's make command get NAMEDATALEN parameter?

Yes,working solution is replace library, copy from master.

laurenz commented 11 months ago

NAMEDATALEN is part of PostgreSQL's PG_MODULE_MAGIC (see the source), which guarantees that you cannot load a library into the server if the module is built against an incompatibly configured PostgreSQL.

Are you saying that the PostgreSQL installations on your primary and your standby were built with different NAMEDATALEN definitions? That would be disastrous, and PostgreSQL should refuse to replicate in such a case (but I am not certain that it does).

Germes1 commented 11 months ago

Postgres parameter max_identifier_length is 63 on both servers, and replication is working. But NAMEDATALEN defined as 256 in /usr/include/postgresql/pg_config_manual.h and /usr/include/postgresql/11/server/pg_config_manual.h on replica. I changed it to 64 and run make, but size did not change. Probably, Postgres was installed from different sources, or recompiled. I'll try to reinstall it. Thank you.

laurenz commented 11 months ago

Interesting. That would suggest that your headers don't belong to the server. But good that you got it fixed.