Following the discussion in How do bindings get an appropriate copy of `fdb_c`?, it looks like it would be a great help if bindings and/or custom deployment scripts could be able to detect the version of a currently running fdb cluster, without requiring to have the appropriate version of libfdb_c
installed.
The goal would be to detect the current version (let say 5.1.7 currently), then obtain the corresponding libfdb_c
library, either by downloading it from a private repo or directlty from foundationdb.org, and then we could be in the expected situation of having a matching libfdb_c version installed for bindings to use.
Currently, you need an already existing compatible version of libfdb_c (so for our example, at least an 5.1.x version) to bootstrap the process.
For custom scripts that must deploy an application without previous knowledge of the running cluster version, this can be tricky.
For example, today I create a custom installation script that targets fdb 5.1.x, and I ship a version of my binding that supports at least API version 510, and in the setup I also ship libfdb_c_5.1.7.dll
. Assuming I also instruct the adminsys to setup a 5.1.x cluster for the application to use, this will work fine.
But let’s say in 2 or 3 years, the fdb cluster has already been upgraded to something like v7.1.x, and all the sudden a major event wipes the application server and they must be reinstalled using the initial setup script (or maybe they move to a new datacenter, a new OS version, etc…). During all that, the fdb cluster is stil running fine and will stay at version 7.1
The custom script will reinstall libfdb_5_1_7.dll but then it will not be able to connect to the cluster, and all the error messages will probably not give me the actual cluster version. So the customer will have to get in contact, and request an updated version of the installation script. Or maybe if they know about the problem, they would need to customize the install package themselves to replace the libfdbc after install (not easy to do with MSI or custom package systems).
An ideal solution would be that all (future) versions of libfdb_c would have an additional API that would use a very simple way to get the current version of a cluster:
- the custom script could load any version of libfdb_c it has, call this method, and get the current version.
- if the version matches the currently loaded libfdb_c then proceed with the rest of the installation as planed.
- if the version does not matches:
- either abort with an explicit error message:
"You need to download version x.y from foobar.org and place in this folder / edit this file / etc.."
- download the library itself from any source, replace the library with the appropriate one, and then continue the install.
- either abort with an explicit error message:
As a side bonus, if a binding would load the currently deployed libfdb_c library, and start getting errors about the version not matching the cluster, it could call the same API and display a more useful error message: "you libfdc_c library found at /path/to/somewhere is version X.x but the cluster is version Y.y that is not compatible. You need to updadate the library and restart the process."
notes:
- I don’t think we can rely on using
fdbcli
because if we have a running fdbcli installed locally, then it means we already have the client binaries installed on the app server, and here we are talking about custom deployment scenarios. - the library would probably need to get access to a valid
fdb.cluster
that would probably be in a custom path, so the API would need to request the path to the cluster file. - I’m not sure if the cluster name is still require to be “DB”, but if it can change in the future, the API should also ask for this.
Something like this?
int fdb_get_cluster_version(char* cluster_file, char* db_name)
I’m not sure if it should return the current version in the same format as the API version, so 517
, or may a more traditional version string like 5.1.7
? It should also be able to return an error code signaling that the version of the cluster is so different that it does not even support this request anymore.