fdb-kubernetes-operator: three_data_hall inconsistent connection string problem

What happened?

I have found a quirky issue happening when using three_data_hall; the issue consists in the k8s FoundationDB cluster status containing an outdated connection string which does not correspond to what the cluster is currently using:

A:  connectionString:     mydb:dZiqyRWzkuM8tZ6hHx4Z3xWsFdu4BV0F@10.10.2.18:4501,10.20.22.84:4501,10.20.60.215:4501,10.20.67.98:4501,10.20.81.100:4501,10.10.265.72:4501,10.20.217.63:4501,10.20.240.122:4501,10.20.243.153:4501
A:  seedConnectionString: <none>

B:  seedConnectionString: mydb:mCYmFHPkEfyKO5gl8ae5ocZPq2a0IJW4@10.10.20.248:4501,10.20.22.192:4501,10.20.67.101:4501,10.10.210.33:4501,10.10.241.115:4501,10.10.268.53:4501,10.10.277.35:4501,10.10.285.107:4501,10.20.220.3:4501
B:  connectionString: mydb:9pION4FdMvW53gB4ikdjo61cs7HQKtK3@10.20.22.84:4501,10.20.60.215:4501,10.20.67.98:4501,10.20.81.100:4501,10.10.220.14:4501,10.10.265.72:4501,10.20.200.1:4501,10.20.217.63:4501,10.20.243.153:4501

C:  seedConnectionString: mydb:mCYmFHPkEfyKO5gl8ae5ocZPq2a0IJW4@10.10.20.248:4501,10.20.22.192:4501,10.20.67.101:4501,10.10.210.33:4501,10.10.241.115:4501,10.10.268.53:4501,10.10.277.35:4501,10.10.285.107:4501,10.20.220.3:4501
C:  connectionString: mydb:dZiqyRWzkuM8tZ6hHx4Z3xWsFdu4BV0F@10.10.2.18:4501,10.20.22.84:4501,10.20.60.215:4501,10.20.67.98:4501,10.20.81.100:4501,10.10.265.72:4501,10.20.217.63:4501,10.20.240.122:4501,10.20.243.153:4501

When checking directly via get \xff\xff/connection_string, the correct connection string for the cluster appears to be the one with generation ID 9pION4FdMvW53gB4ikdjo61cs7HQKtK3.

What did you expect to happen?

The operator-maintained connection string field should always match get \xff\xff/connection_string.

How can we reproduce it (as minimally and precisely as possible)?

  1. trigger pod rotation of some pods in data hall A; for example coordinators, by changing something in the podTemplate for coordinators
  2. repeat for for halls B and C until issue is manifest

Anything else we need to know?

Related: #1958

By my analysis the client issues are symptoms and not the cause: there is always going to be a client with an incorrect connection string if the operator-provided configmap does not contain the same connection string for all halls.

FDB Kubernetes operator

v1.47.0

Kubernetes version

$ kubectl version
Client Version: v1.29.3
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Server Version: v1.30.4-eks-a737599

Cloud provider

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 20 (20 by maintainers)

Most upvoted comments

Where are you running that fdbcli command? \xff\xff/connection_string will show the current content of the connection string (not necessary the connection string from the DB).

Thanks, will take note of this. I have been using a random pod to check this.

The operator should be logging a message when the connection string from the DB is different from the one stored in the status: https://github.com/FoundationDB/fdb-kubernetes-operator/blob/main/controllers/cluster_controller.go#L580-L586 and it will log when the ConfigMap is updated: https://github.com/FoundationDB/fdb-kubernetes-operator/blob/main/controllers/update_config_map.go#L72-L80.

What about that update_status.go failure in logs? Is it OK to fail there e.g. something else will later update the status anyways?

In the next reconciliation run the operator should update the ConfigMap.

In general it’s recommended to not use the cluster file from the ConfigMap directly but rather copy it to a writable file to allow the clients to update their cluster file directly when coordinators are changed.

Thanks, I think all clients are using OpenWithConnectionString except a couple, will fix them too.

From the FDB bindings:

// OpenWithConnectionString returns a database handle to the FoundationDB cluster identified
// by the provided connection string. This method can be useful for scenarios where you want to connect
// to the database only for a short time e.g. to test different connection strings.
// Caller must call Close() to release resources.

https://github.com/apple/foundationdb/blob/main/bindings/go/src/fdb/fdb.go#L408-L413 and based on your description it rather seems like you are having long running clients. But I would need to look inside the code to answer your question properly (I’ll try to find some time for this). The current recommendation would be to copy the cluster file with an init container to a place that is writable, e.g.: https://github.com/FoundationDB/fdb-kubernetes-operator/blob/main/config/samples/client.yaml#L42-L59.

Yesterday I found another instance of this problem, but it was slightly different:

  • all 3 connection strings in the Kubernetes FoundationDBCluster status were the same
  • they were all different from the actual one used by cluster (get \xff\xff/connection_string)

@johscheuer let me know if I should do some other test or provide more information

The operator should notice that the connection strings are not matching: https://github.com/FoundationDB/fdb-kubernetes-operator/blob/v1.47.0/controllers/cluster_controller.go#L580-L586 and updates the connection string in the FoundationDBCluster resource and then the updateStatus reconciler will update the FoundationDBCluster resource status: https://github.com/FoundationDB/fdb-kubernetes-operator/blob/v1.47.0/controllers/update_status.go#L254-L263.

Thanks for the explanation; is the unified image considered stable by now?

It’s considered stable and can be used in production, but please test it first in your dev/test environment. If anything doesn’t work as expected please create a GitHub issue for it.

I am indeed using the default split image; however the issue never resolves by itself (it’s not a matter of waiting longer, stays intact also for days) unless I manually fix it or trigger further rotations.

Interesting, I would have thought that after some time (I think the default reconciliation period is 10h) the connection string will be updated by the operator. Has the operator reconciled in that time? I would expect it didn’t execute another reconciliation loop in this case.

This is a known issue when multiple operator instances are used (like in the multi-region setup or in three-data-hall). I assume you used the split image as this is the default. In the newer unified image we added a propagation mechanism to reduce the time between an out-dated connection string. The TLDR here is that the fdb-kubernetes-monitor updates an annotation when the local cluster file changes (which is the case when the connection string is updated). The annotation change will then trigger a new reconciliation loop and the operator will update the FoundationDBCluster resource and the ConfigMap.

I change the label to question as we fixed it in the unified image and we have no plans to fix it for the split image.