Replication factor not getting recovered

Hi All,
I am facing an issue :
we have two node setup running ipfs and ipfs-cluster.
we bring one node down and try to pin a CID using the ipfs-cluster-ctl command with replication factor of 2. This command is successful with CID pinned in one node. When we bring the other node up, CID gets pinned in other nodes too as earlier we gave a replication factor of 2.

when i try to pin using ipfs-cluster client using below code :

        pinOptions := api.PinOptions{}
	pinOptions.ReplicationFactorMin = 1 
	pinOptions.ReplicationFactorMax = pinReq.ReplicationFactor -> this value is 2
	pinOptions.Mode = api.PinModeRecursive
	pinStatus, err := ipfsclusterclient.Pin(req.Context(), cidReceived, pinOptions)
	if err != nil {
		kiplog.KIPError(ctxData.RequestID, errors.New(" failed to get pin status "+err.Error()), nil)
		core.WriteHTTPErrorResponse(w, ctxData.RequestID, failedClusterClient, http.StatusBadRequest, err)
		return
	}

So when i pin the CID with one node down, it’s getting pinned in one node , but when we bring back the second node , CID is not getting pinned in the second node similar to what is happening with ipfs-cluster-ctl. Status of CID in the second node shows as remote but my expectation was to see it as pinned.
Not sure what i am missing here. Can anybody help please.

Thanks,
Pankaj

In your request you specify that replication factor min = 1.

When you pin, there is only 1 peer available. So the pin will be allocated to that peer only.

When the second peer comes up, it does pin anything because the pin has not been allocated to it in the first place.

So essentially, at the moment when the request to pin is received, cluster will try to find an allocation based on the options and will satisfy it based on the current cluster peers. That will either work or not, but cluster will not check later because the pin is still above replication-factor min.

This is how things work now, though I understand that it would be nice if cluster would automatically allocate up to replication-factor-max when other peers join.

The strange thing to me here is, when I use "ipfs-cluster-ctl pin add “CID” --replication 2 " command with one node down, it initially gets pinned in one node only but later when the second node comes up, it gets automatically pinned in the second node too. It seems to me that when using the command line we are allocating pin even to the node which is up but pinning from the ipfs-cluster-client i get an error saying " not enough candidate to pin " when try pinning with min replication factor of 2.

No, that should not be that way. It may be that you brought one node down, but it’s metrics had not expired when you tried the operation. Therefore the other node still thinks it is “up” and allocates to it.

“add” goes through the same allocation process as “pin” and if a node is down it is not included in the allocations for the pin (to the best of my knowledge).

ok. Thanks for the quick response hector. I will cross-check the behavior.