In the current implementation of Golang bindings one has a small potential(!) bug
Limitation
// In the current release, the database name must be []byte("DB").
Global variable
var openDatabases map[string]Database
function itself
....
db, ok := openDatabases[string(dbName)]
if !ok {
db, e = cluster.OpenDatabase(dbName)
if e != nil {
return Database{}, e
}
openDatabases[string(dbName)] = db
}
...
So opening a second cluster file just replaces a variable in a mapping. Good news is that openDatabases variable is not used anymore in bindings, so one should be ok as long as have a direct fdb.Database handle reference.
It seems to me like this is a bug. Suppose I have two clusters with two cluster files, “fdb.a.cluster” and “fdb.b.cluster”. What happens if I do the following:
dbName := []byte("DB") // or however this is done in go
dbA := fdb.MustOpen("fdb.a.cluster", dbName)
dbB := fdb.MustOpen("fdb.b.cluster", dbName)
Then dbA should correctly open a connection to “fdb.a.cluster” whereas dbB will point to “fdb.a.cluster” as well because the Open logic will notice that the cluster connection isn’t present and create a new one, but then the database object cache will see that there is already a database created with the (only valid) database name string and return it instead of a connection to “fdb.b.cluster”, which seems pretty bad.
If my understanding is correct, then I think this should probably be an issue on GitHub.