josephg / node-foundationdb

Modern Node.js FoundationDB bindings
Other
117 stars 18 forks source link

foundationdb@1.1.2 doesn't support 600 API version #61

Open mitya-borodin opened 3 years ago

mitya-borodin commented 3 years ago

I try to set up 600 API version:

import * as fdb from 'foundationdb';

fdb.setAPIVersion(600);

and I catch error:

Error: API version not supported
    at Object.set (/opt/app/node_modules/foundationdb/lib/apiVersion.ts:35:42)
[ERROR] 13:46:05 Error: API version not supported
josephg commented 3 years ago

Works fine for me. What version of foundationdb do you have installed? (Find out with fdbcli --version)

$ fdbcli --version
FoundationDB CLI 6.2 (v6.2.28)
aikoven commented 3 years ago

We currently use FDB version 6.2.15, FDB client version 6.2.28. This problem only occurs on lib version 1.1.2, but everything is fine for 1.1.1.

josephg commented 3 years ago

Reproduced this issue on fdb 6.2.15.

josephg commented 3 years ago

Yeah, I'm not sure what the right approach is here. I've reached out to the foundationdb developers forum about it to see if anyone has a recommendation about how to proceed.

The issue is that foundationdb 6.2.15 doesn't support API version 630 and bumping the header version unfortunately has had the downstream consequence of increasing the minimum supported version of foundationdb.

There's no new changes in node-foundationdb@1.1.2 except adding support for API version 630, and if you're using foundationdb 6.2.15 then you can't use those new features anyway.

So workarounds, in order of preference:

  1. Stick to foundationdb@1.1.1 for now. I'm sorry, this is a breaking API change and shouldn't have happened in a patch version. (I take responsibility, but I get confused by foundationdb's version system every time I look at it.)
  2. Upgrade to a newer version of the foundationdb database. (Bleh.)
  3. Call setAPIVersion with a second parameter to override the "header version":
import * as fdb from 'foundationdb';

fdb.setAPIVersion(600, 600)

But I honestly don't understand enough about how the header version is used to know what this will actually do. I think it'll either work or crash instantly. YMMV. Hopefully some of the core foundationdb team have some better suggestions to handle this situation better in the future.

aikoven commented 2 years ago

We managed to solve this using the multi-version client.

Here's a part of the Dockerfile where we install FDB client 6.3.23 and an extra client library version 6.2.30:

# install FoundationDB client library
RUN wget -q https://github.com/apple/foundationdb/releases/download/6.3.23/foundationdb-clients_6.3.23-1_amd64.deb \
  && dpkg -i foundationdb-clients_6.3.23-1_amd64.deb \
  && rm foundationdb-clients_6.3.23-1_amd64.deb

# install older FoundationDB client library for compatibility with 6.2
RUN wget -q https://github.com/apple/foundationdb/releases/download/6.2.30/libfdb_c.x86_64.so \
 && mkdir -p /usr/lib/foundationdb/multiversion \
 && mv libfdb_c.x86_64.so /usr/lib/foundationdb/multiversion/libfdbc_6.2.30.so

# set up multi-version client
ENV FDB_NETWORK_OPTION_EXTERNAL_CLIENT_DIRECTORY /usr/lib/foundationdb/multiversion

We use node-foundationdb of version 1.1.3 and set

fdb.setAPIVersion(620);  // 600 works too

This setup also allows us to upgrade FDB server from 6.2 to 6.3 with no downtime.