Skip to content
Vector database engineering on Kubernetes · Chapter 8 of 20 Day 7: Quorum and partition – when the line is cut

Day 7: Quorum and partition – when the line is cut

Goal: use iptables to cut off one Qdrant node from the rest, then all three from each other, and measure what reading, writing and Raft do – and what fits back together after healing · Duration: about 120 min · Prerequisite: Day 0 to Day 6

State before this chapter

Three Qdrant pods are running, one each on vdb2, vdb3 and vdb4; the PodDisruptionBudget from Day 6 is active.

# on vdb1
kubectl -n qdrant get pods -o wide

Expected (your IPs and ages will differ):

NAME       READY   STATUS    RESTARTS   AGE     IP           NODE   NOMINATED NODE   READINESS GATES
qdrant-0   1/1     Running   0          4h      10.42.1.34   vdb2   <none>           <none>
qdrant-1   1/1     Running   0          3h43m   10.42.3.21   vdb4   <none>           <none>
qdrant-2   1/1     Running   0          3h48m   10.42.2.6    vdb3   <none>           <none>

Remember the three pod IPs. Today you query each pod individually, not through the Service – only then do you see what each side of a split thinks. Wherever the text says 10.42.1.34, 10.42.3.21 or 10.42.2.6, insert your IPs of qdrant-0, qdrant-1 and qdrant-2.

Introduction

Yesterday pods and nodes failed – cleanly, as a whole. Today something more unpleasant fails: the connection between the nodes. All pods keep running, all are Ready, Kubernetes sees nothing. But the Qdrant peers can no longer reach each other.

This is exactly what Raft and the quorum are for: decisions are only made by majority. How this shows up in practice is less obvious. A write request reports an error and is stored anyway. A collection comes into being although the command aborts. A node considers itself the leader although nobody is listening to it anymore.

Today you will learn:

  • to create a network partition with iptables and lift it again, without touching the VM,
  • to read the Raft state of each peer: role, leader, term, commit,
  • to distinguish what still works on the majority side and what on the minority side,
  • why a timeout when writing means “result unknown” – and how to deal with it,
  • to check whether all copies are identical again after healing.

Background

The picture of the day: the cut line

The three buildings of the city library are connected by telephone lines. Decisions about the holdings – which collections exist, which shelf stands in which building – are made by the library council: one representative per building, decisions by majority. One of them chairs the meeting (the leader). Every new chair gets a sequential number (the term). Every decision goes into the minute book and gets a page number (the commit index).

  • One building is cut off: the other two are two out of three – quorate. The cut-off building keeps calling for a new election, counting up the meeting number each time, but gets no votes.
  • All lines are dead: nobody has a majority. The previous chair still believes he is chairing the meeting – only he no longer passes a single decision.
  • Lending (reading and writing points) needs no council decision. It does need the shelves, though: anyone who wants to answer a question about the whole collection has to reach every shelf – in their own building or by phone.

The terms

Term Meaning In the picture
Partition nodes are running, but cannot reach each other telephone line cut
Raft protocol by which the peers agree on metadata (collections, shard distribution, replica states) library council
Quorum majority of the peers: with three, it is two quorate
Leader / Follower / Candidate roles in Raft: leads, follows, wants to be elected chair, member, candidate
Term number of the current election period, increases with every election meeting number
Commit index of the last decision confirmed by the majority page in the minute book
Replica state Dead copy is considered outdated and no longer receives requests second copy locked

Remember: Raft decides about the holdings, not about every loan. Without a majority there are no new decisions – but reading and writing go on, as far as the shelves can be reached.

Drill 1: Who chairs the council?

Where you are: on vdb1.

What you have afterwards: the Raft state of all three peers before the split.

Step 1 – create a working folder.

# on vdb1
mkdir -p ~/labor/tag07
# on vdb1
cd ~/labor/tag07

Step 2 – query the state of qdrant-0. The endpoint /cluster describes what this one peer knows about the cluster. You save the response and then read it with jq.

# on vdb1
curl -s http://10.42.1.34:6333/cluster -o k0.json
# on vdb1
jq -c '.result | {peer_id, role: .raft_info.role, leader: .raft_info.leader, term: .raft_info.term, commit: .raft_info.commit}' k0.json
  • .result is the payload part of every Qdrant response.
  • .raft_info.role, .leader, .term, .commit are the four values from the terms table.

Expected (your peer IDs and numbers will differ):

{"peer_id":121400021250061,"role":"Leader","leader":121400021250061,"term":113,"commit":86}

Step 3 – the same for qdrant-1 and qdrant-2.

# on vdb1
curl -s http://10.42.3.21:6333/cluster -o k1.json
# on vdb1
jq -c '.result | {peer_id, role: .raft_info.role, leader: .raft_info.leader, term: .raft_info.term, commit: .raft_info.commit}' k1.json

Expected:

{"peer_id":857928665674298,"role":"Follower","leader":121400021250061,"term":113,"commit":86}
# on vdb1
curl -s http://10.42.2.6:6333/cluster -o k2.json
# on vdb1
jq -c '.result | {peer_id, role: .raft_info.role, leader: .raft_info.leader, term: .raft_info.term, commit: .raft_info.commit}' k2.json

Expected:

{"peer_id":1485700002748332,"role":"Follower","leader":121400021250061,"term":113,"commit":86}

What you see: all three agree: same leader, same term, same commit. For us, qdrant-0 is the leader. Note down which peer ID belongs to which pod – you will need this shortly.

Pod Node Peer ID for us Role
qdrant-0 vdb2 121400021250061 Leader
qdrant-1 vdb4 857928665674298 Follower
qdrant-2 vdb3 1485700002748332 Follower

Step 4 – where are the shelves? You know from Day 5: verteilt has three shards with two copies each. Which copy is where is shown by /collections/verteilt/cluster, here from the view of qdrant-2:

# on vdb1
curl -s http://10.42.2.6:6333/collections/verteilt/cluster -o v2.json
# on vdb1
jq -c '.result | {local: [.local_shards[]|{shard_id,state,points_count}], remote: [.remote_shards[]|{shard_id,peer_id,state}]}' v2.json

Expected:

{"local":[{"shard_id":0,"state":"Active","points_count":4089},{"shard_id":1,"state":"Active","points_count":4702}],"remote":[{"shard_id":0,"peer_id":121400021250061,"state":"Active"},{"shard_id":1,"peer_id":857928665674298,"state":"Active"},{"shard_id":2,"peer_id":121400021250061,"state":"Active"},{"shard_id":2,"peer_id":857928665674298,"state":"Active"}]}

What you see: qdrant-2 holds shards 0 and 1 itself; shard 2 is only on the other two. For us the whole distribution looks like this:

Shard Copy on Copy on
0 qdrant-0 qdrant-2
1 qdrant-1 qdrant-2
2 qdrant-0 qdrant-1

The collection doku has a single shard with copies on qdrant-0 and qdrant-1 (Day 5).

Remember: /cluster shows the view of one peer. During a partition you therefore ask each one individually – the Service would give you a random view.

Save your progress? Sign up for free

Drill 2: Two helpers for writing and counting

Where you are: on vdb1, in ~/labor/tag07.

What you have afterwards: one program that writes individual test points and reports every error, and one that counts them.

Step 1 – the write program. Each point is written individually so that you can see for each one whether it worked. The points carry quelle: tag07 in their payload so that you can find and delete them later.

# on vdb1
nano schreiben.py
~/labor/tag07/schreiben.py new file
"""Schreibt einzelne Testpunkte in eine Collection und meldet jeden Erfolg oder Fehler."""
import sys
import time

import numpy as np
from qdrant_client import QdrantClient, models

QDRANT, COLLECTION, START, ANZAHL = sys.argv[1], sys.argv[2], int(sys.argv[3]), int(sys.argv[4])

vektoren = np.load("../tag01/vektoren.npy")
client = QdrantClient(url=QDRANT, timeout=5)

for nummer in range(START, START + ANZAHL):
    punkt = models.PointStruct(id=nummer, vector=vektoren[nummer % len(vektoren)].tolist(),
                               payload={"quelle": "tag07"})
    try:
        client.upsert(COLLECTION, points=[punkt], wait=True)
        print(f"{time.strftime('%T')} Punkt {nummer}: geschrieben", flush=True)
    except Exception as e:
        print(f"{time.strftime('%T')} Punkt {nummer}: FEHLER {str(e).splitlines()[0][:100]}", flush=True)
  • The four arguments: address, collection, first point ID, count.
  • timeout=5: if Qdrant does not answer within five seconds, the program reports FEHLER timed out.
  • wait=True: Qdrant only answers once the point is stored.
  • The loop is part of the program – you don’t type it as a command.

Step 2 – the count program. It counts all points of the collection and those with quelle: tag07, through exactly the pod whose address you specify.

# on vdb1
nano zaehlen.py
~/labor/tag07/zaehlen.py new file
"""Zählt die Testpunkte aus Tag 7 auf einem einzelnen Qdrant-Pod."""
import sys

from qdrant_client import QdrantClient, models

QDRANT, COLLECTION = sys.argv[1], sys.argv[2]

client = QdrantClient(url=QDRANT, timeout=5)
filter_tag07 = models.Filter(must=[models.FieldCondition(key="quelle", match=models.MatchValue(value="tag07"))])
gesamt = client.count(COLLECTION, exact=True).count
tag07 = client.count(COLLECTION, count_filter=filter_tag07, exact=True).count
print(f"{COLLECTION} auf {QDRANT}: {gesamt} Punkte, davon {tag07} aus Tag 7")

Step 3 – write three points. A trial run through the Service, while everything is connected.

# on vdb1
~/werkbank/bin/python schreiben.py http://10.43.151.237:6333 verteilt 900000 3

Expected:

16:14:34 Punkt 900000: geschrieben
16:14:34 Punkt 900001: geschrieben
16:14:34 Punkt 900002: geschrieben
# on vdb1
~/werkbank/bin/python zaehlen.py http://10.42.2.6:6333 verteilt

Expected:

verteilt auf http://10.42.2.6:6333: 13223 Punkte, davon 3 aus Tag 7

What you see: 13,220 points from the previous days plus your three.

Remember: for failure experiments you need test data you can recognize. A payload field like quelle: tag07 turns counting and cleaning up into a single filter.

Save your progress? Sign up for free

Drill 3: One building is cut off

Where you are: on vdb3 and vdb1.

What you have afterwards: qdrant-2 separated from the rest – and measured what both sides can still do.

Step 1 – cut off vdb3. On vdb3 you drop every packet from and to vdb2 and vdb4. The connection to vdb1 stays: the node stays Ready for Kubernetes, and you can keep querying every pod from vdb1. The pod-to-pod packets travel over the node IPs (flannel VXLAN), which is why the rule also hits Qdrant.

# on vdb3
sudo iptables -I INPUT -s 172.16.0.126 -j DROP
Setting Value Meaning
-I INPUT insert the rule at the very top of the chain for incoming packets
-s 172.16.0.126 sender: vdb2
-j DROP silently drop the packet – the sender waits until its timeout kicks in

The same for vdb4 and for the outgoing direction. Each rule individually:

# on vdb3
sudo iptables -I INPUT -s 172.16.0.228 -j DROP
# on vdb3
sudo iptables -I OUTPUT -d 172.16.0.126 -j DROP
  • -I OUTPUT applies to packets that vdb3 sends; -d is the destination.
# on vdb3
sudo iptables -I OUTPUT -d 172.16.0.228 -j DROP

The four commands print nothing. A look at the input chain:

# on vdb3
sudo iptables -L INPUT -n --line-numbers
  • -L INPUT lists the chain, -n shows IPs instead of names, --line-numbers numbers the rules.

Expected (excerpt – the first lines; the k3s chains follow below):

Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination         
1    DROP       0    --  172.16.0.228         0.0.0.0/0           
2    DROP       0    --  172.16.0.126         0.0.0.0/0           
3    KUBE-ROUTER-INPUT  0    --  0.0.0.0/0            0.0.0.0/0            /* kube-router netpol - 4IA2OSFRMVNDXBVV */

The rules only apply until the next reboot. If something goes wrong, a sudo reboot on vdb3 lifts the split.

Step 2 – what Kubernetes sees. Half a minute later, back on vdb1:

# on vdb1
kubectl -n qdrant get pods -o wide

Expected:

NAME       READY   STATUS    RESTARTS   AGE     IP           NODE   NOMINATED NODE   READINESS GATES
qdrant-0   1/1     Running   0          4h1m    10.42.1.34   vdb2   <none>           <none>
qdrant-1   1/1     Running   0          3h44m   10.42.3.21   vdb4   <none>           <none>
qdrant-2   1/1     Running   0          3h49m   10.42.2.6    vdb3   <none>           <none>

What you see: nothing. All three Ready. The readiness probe asks each pod on its own node, and it answers there.

Step 3 – what Raft sees. Repeat the three queries from Drill 1.

# on vdb1
curl -s http://10.42.1.34:6333/cluster -o k0.json
# on vdb1
jq -c '.result | {peer_id, role: .raft_info.role, leader: .raft_info.leader, term: .raft_info.term, commit: .raft_info.commit}' k0.json

Expected:

{"peer_id":121400021250061,"role":"Leader","leader":121400021250061,"term":113,"commit":86}

For qdrant-1 (k1.json) we still see Follower, leader qdrant-0, term 113. And qdrant-2:

# on vdb1
curl -s http://10.42.2.6:6333/cluster -o k2.json
# on vdb1
jq -c '.result | {peer_id, role: .raft_info.role, leader: .raft_info.leader, term: .raft_info.term, commit: .raft_info.commit}' k2.json

Expected (your term will differ and keeps rising):

{"peer_id":1485700002748332,"role":"Candidate","leader":0,"term":124,"commit":86}

What you see: the majority (qdrant-0 and qdrant-1) carries on as before. qdrant-2 no longer knows a leader (leader: 0), applies for the role (Candidate) and counts up the term with every unsuccessful election – from 113 to 124 in 30 seconds.

Step 4 – write through the majority.

# on vdb1
~/werkbank/bin/python schreiben.py http://10.42.1.34:6333 verteilt 900010 6

Expected (which IDs fail depends on which shard they fall on):

16:15:40 Punkt 900010: FEHLER timed out
16:15:45 Punkt 900011: FEHLER timed out
16:15:50 Punkt 900012: FEHLER timed out
16:15:50 Punkt 900013: geschrieben
16:15:50 Punkt 900014: geschrieben
16:15:50 Punkt 900015: geschrieben

What you see: the first three run into the timeout, after that it works immediately. What happened in those 15 seconds is shown by qdrant-0’s view of verteilt:

# on vdb1
curl -s http://10.42.1.34:6333/collections/verteilt/cluster -o v0.json
# on vdb1
jq -c '.result | {local: [.local_shards[]|{shard_id,state}], remote: [.remote_shards[]|{shard_id,peer_id,state}]}' v0.json

Expected:

{"local":[{"shard_id":0,"state":"Active"},{"shard_id":2,"state":"Active"}],"remote":[{"shard_id":0,"peer_id":1485700002748332,"state":"Active"},{"shard_id":1,"peer_id":857928665674298,"state":"Active"},{"shard_id":1,"peer_id":1485700002748332,"state":"Dead"},{"shard_id":2,"peer_id":857928665674298,"state":"Active"}]}

What you see: the copy of shard 1 on qdrant-2 (peer 1485700002748332) is now Dead. The council decided this state by majority. Since then, nobody waits for qdrant-2 for shard 1 anymore, and every write goes through immediately. For us the copy of shard 0 on qdrant-2 was still Active – in an earlier run both were Dead. Which copy gets locked when was not the same every time for us.

Step 5 – are the “failed” points there?

# on vdb1
~/werkbank/bin/python zaehlen.py http://10.42.1.34:6333 verteilt

Expected:

verteilt auf http://10.42.1.34:6333: 13229 Punkte, davon 9 aus Tag 7

What you see: 9 = 3 from Drill 2 + all 6 from Step 4. The three points with FEHLER timed out are therefore stored. The client gave up after five seconds, Qdrant kept working.

Step 6 – the minority. Now the same attempts through qdrant-2.

# on vdb1
~/werkbank/bin/python schreiben.py http://10.42.2.6:6333 verteilt 900020 3

Expected:

16:16:02 Punkt 900020: FEHLER timed out
16:16:07 Punkt 900021: FEHLER timed out
16:16:12 Punkt 900022: FEHLER timed out
# on vdb1
~/werkbank/bin/python ../tag06/lesen.py http://10.42.2.6:6333 verteilt 8

Expected:

16:16:18 FEHLER: timed out
16:16:25 Ende: 0 Antworten, 4 Fehler

What you see: qdrant-2 can neither write nor search. A search over verteilt needs all three shards, but shard 2 is only on the peers that qdrant-2 cannot reach. For doku, qdrant-2 has no copy at all – there too we only got timed out.

Step 7 – through the Service. What does a client see that uses the Service as usual?

# on vdb1
~/werkbank/bin/python ../tag06/lesen.py http://10.43.151.237:6333 verteilt 20

Expected:

16:16:36 antwortet
16:16:56 Ende: 75 Antworten, 0 Fehler

What you see: no error this time. In an earlier run the same command looked like this:

16:03:24 FEHLER: timed out
16:03:25 antwortet (vorher 0.3 s)
16:03:43 Ende: 67 Antworten, 1 Fehler

The prober keeps a connection open, and the Service decides when it is established which pod gets it. If it lands on a healthy pod, the prober notices nothing. If it lands on qdrant-2, the request runs into the timeout and the new connection lands elsewhere. This cannot be predicted as long as qdrant-2 is listed as Ready in the Service.

Remember: Kubernetes does not see a partition. The majority locks the cut-off copies and carries on, the minority no longer answers anything – but keeps receiving requests from the Service.

Save your progress? Sign up for free

Drill 4: A decision during the split

Where you are: on vdb1, vdb3 is still cut off.

What you have afterwards: seen how a new collection arrives on both sides of the split.

Step 1 – through the minority. A new collection is a council decision.

# on vdb1
curl -s -m 15 -X PUT http://10.42.2.6:6333/collections/probe2 -H 'Content-Type: application/json' -d '{"vectors":{"size":4,"distance":"Cosine"}}'
Setting Value Meaning
-m 15 abort after 15 seconds
-X PUT Qdrant creates collections with PUT
-H Content-Type: application/json the body is JSON
-d {"vectors":…} tiny test vectors: four values, cosine

Expected:

{"status":{"error":"Service internal error: Failed to propose operation: leader is not established within 10s"},"time":10.01368564}

What you see: a clear refusal: no leader, no decision.

Step 2 – through the majority.

# on vdb1
curl -s -m 15 -X PUT http://10.42.1.34:6333/collections/probe -H 'Content-Type: application/json' -d '{"vectors":{"size":4,"distance":"Cosine"}}'

Expected: no output – after 15 seconds curl aborts.

# on vdb1
curl -s http://10.42.1.34:6333/collections -o c.json
# on vdb1
jq -c .result c.json

Expected:

{"collections":[{"name":"doku"},{"name":"probe"},{"name":"verteilt"}]}

What you see: probe exists anyway. How it is doing is the diagnosis task at the end of the chapter.

Remember: the minority rejects decisions immediately. The majority passes them – but whatever parts of them need the cut-off building get stuck.

Save your progress? Sign up for free

Drill 5: Restoring the line

Where you are: on vdb3 and vdb1.

What you have afterwards: the split lifted and checked whether the copies are identical again.

Step 1 – delete the rules. -D instead of -I removes exactly the rule with these settings.

# on vdb3
sudo iptables -D INPUT -s 172.16.0.126 -j DROP
# on vdb3
sudo iptables -D INPUT -s 172.16.0.228 -j DROP
# on vdb3
sudo iptables -D OUTPUT -d 172.16.0.126 -j DROP
# on vdb3
sudo iptables -D OUTPUT -d 172.16.0.228 -j DROP
# on vdb3
sudo iptables -L INPUT -n

Expected (excerpt – the first lines, no DROP rule anymore):

Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
KUBE-ROUTER-INPUT  0    --  0.0.0.0/0            0.0.0.0/0            /* kube-router netpol - 4IA2OSFRMVNDXBVV */

Step 2 – qdrant-2 comes back. Immediately afterwards on vdb1:

# on vdb1
curl -s http://10.42.2.6:6333/cluster -o k2.json
# on vdb1
jq -c '.result.raft_info | {role, leader, term, commit}' k2.json

Expected (four seconds after deleting the first rule):

{"role":"Follower","leader":0,"term":172,"commit":86}

Twelve seconds later, the same command:

{"role":"Follower","leader":121400021250061,"term":174,"commit":106}

What you see: qdrant-2 had counted the term up from 113 to 172 in three minutes. On its return, this high term forces the council into a new election – term 174, and qdrant-0 is elected again. The commit jumps from 86 to 106: qdrant-2 catches up on the decisions made without it, including probe and the Dead markings.

Step 3 – check the copies. From the view of qdrant-0:

# on vdb1
curl -s http://10.42.1.34:6333/collections/verteilt/cluster -o v0.json
# on vdb1
jq -c '[.result.remote_shards[]|select(.peer_id==1485700002748332)|{shard_id,state}]' v0.json
  • select(.peer_id==…) keeps only the copies on qdrant-2; insert your peer ID.

Expected (for us ten seconds after healing):

[{"shard_id":0,"state":"Active"},{"shard_id":1,"state":"Active"}]

And the point count of each copy, on each pod individually. Here qdrant-2:

# on vdb1
curl -s http://10.42.2.6:6333/collections/verteilt/cluster -o v2.json
# on vdb1
jq -c '{peer: .result.peer_id, local: [.result.local_shards[]|{shard_id,points_count,state}]}' v2.json

Expected:

{"peer":1485700002748332,"local":[{"shard_id":0,"points_count":4092,"state":"Active"},{"shard_id":1,"points_count":4706,"state":"Active"}]}

On qdrant-0, shard 0 also showed 4092 points for us, and on qdrant-1, shard 1 also showed 4706.

What you see: the Dead copy has loaded the missed points and is Active again. Each shard has the same count on both pods.

Step 4 – what became of the minority points?

# on vdb1
curl -s -X POST http://10.43.151.237:6333/collections/verteilt/points -H 'Content-Type: application/json' -d '{"ids":[900020,900021,900022,900010,900011,900012]}' -o p.json
  • POST …/points with ids fetches exactly these points.
# on vdb1
jq -c '[.result[].id]' p.json

Expected:

[900010,900011,900012]

What you see: the three points that “failed” through the majority are there. The three through the minority are not – they were never stored, not even afterwards.

Remember: after healing, what counts is what the majority decided. The minority loses nothing, because it accepted nothing.

Save your progress? Sign up for free

Drill 6: No majority anymore

Where you are: on vdb2, vdb3 and vdb1.

What you have afterwards: all three peers separated from each other and seen what still works without a quorum.

Step 1 – separate vdb2 from vdb3 and vdb4. The same rules as in Drill 3, only on vdb2:

# on vdb2
sudo iptables -I INPUT -s 172.16.0.83 -j DROP
# on vdb2
sudo iptables -I INPUT -s 172.16.0.228 -j DROP
# on vdb2
sudo iptables -I OUTPUT -d 172.16.0.83 -j DROP
# on vdb2
sudo iptables -I OUTPUT -d 172.16.0.228 -j DROP

Step 2 – separate vdb3 from vdb4. With that, every one of the three lines is cut.

# on vdb3
sudo iptables -I INPUT -s 172.16.0.228 -j DROP
# on vdb3
sudo iptables -I OUTPUT -d 172.16.0.228 -j DROP

Step 3 – the three views. Half a minute later you query all three pods as in Drill 1 (k0.json, k1.json, k2.json).

Expected (one line per pod, in the order qdrant-0, qdrant-1, qdrant-2):

{"peer_id":121400021250061,"role":"Leader","leader":121400021250061,"term":174,"commit":106}
{"peer_id":857928665674298,"role":"Candidate","leader":0,"term":182,"commit":106}
{"peer_id":1485700002748332,"role":"Candidate","leader":0,"term":183,"commit":106}

What you see: qdrant-0 still calls itself Leader – although nobody is listening to it anymore. The other two apply for the role and count up. The role alone therefore does not tell you whether there is a majority.

Step 4 – a decision at the “leader”.

# on vdb1
curl -s -m 15 -X PUT http://10.42.1.34:6333/collections/probe3 -H 'Content-Type: application/json' -d '{"vectors":{"size":4,"distance":"Cosine"}}'

Expected:

{"status":{"error":"Service internal error: Waiting for consensus operation commit failed. Timeout set at: 10 seconds"},"time":10.006417389}

What you see: the leader proposes the decision, but nobody confirms it. After ten seconds it gives up – that is the honest hint at the missing quorum.

Step 5 – read. doku has one shard with copies on qdrant-0 and qdrant-1.

# on vdb1
~/werkbank/bin/python ../tag06/lesen.py http://10.42.1.34:6333 doku 3

Expected:

16:19:21 antwortet
16:19:24 Ende: 12 Antworten, 0 Fehler

Through qdrant-1 (10.42.3.21) we got 12 answers and 0 errors, through qdrant-2 (10.42.2.6) 0 answers and 2 errors.

What you see: search continues without a quorum – wherever a complete copy stands in the building itself.

Step 6 – write.

# on vdb1
~/werkbank/bin/python schreiben.py http://10.42.1.34:6333 verteilt 900040 4

Expected:

16:19:45 Punkt 900040: FEHLER timed out
16:19:50 Punkt 900041: FEHLER timed out
16:19:50 Punkt 900042: geschrieben
16:19:51 Punkt 900043: geschrieben

And the state of the copies from the view of qdrant-0:

# on vdb1
curl -s http://10.42.1.34:6333/collections/verteilt/cluster -o v0.json
# on vdb1
jq -c '.result | {local: [.local_shards[]|{shard_id,state,points_count}], remote: [.remote_shards[]|{shard_id,peer_id,state}]}' v0.json

Expected:

{"local":[{"shard_id":0,"state":"Active","points_count":4092},{"shard_id":2,"state":"Active","points_count":4434}],"remote":[{"shard_id":0,"peer_id":1485700002748332,"state":"Active"},{"shard_id":1,"peer_id":857928665674298,"state":"Active"},{"shard_id":1,"peer_id":1485700002748332,"state":"Active"},{"shard_id":2,"peer_id":857928665674298,"state":"Active"}]}

What you see: unlike in Drill 3, no copy is Dead. Locking a copy is a council decision – and there is none without a majority. Shard 2 on qdrant-0 has grown nevertheless (4431 → 4434).

Step 7 – heal. Remove all six rules again, each individually with -D:

# on vdb2
sudo iptables -D INPUT -s 172.16.0.83 -j DROP
# on vdb2
sudo iptables -D INPUT -s 172.16.0.228 -j DROP
# on vdb2
sudo iptables -D OUTPUT -d 172.16.0.83 -j DROP
# on vdb2
sudo iptables -D OUTPUT -d 172.16.0.228 -j DROP
# on vdb3
sudo iptables -D INPUT -s 172.16.0.228 -j DROP
# on vdb3
sudo iptables -D OUTPUT -d 172.16.0.228 -j DROP

Step 8 – what remained? A minute later:

# on vdb1
curl -s -X POST http://10.43.151.237:6333/collections/verteilt/points -H 'Content-Type: application/json' -d '{"ids":[900040,900041,900042,900043]}' -o p.json
# on vdb1
jq -c '[.result[].id]' p.json

Expected:

[900040,900042,900043]
# on vdb1
curl -s http://10.42.1.34:6333/collections -o c.json
# on vdb1
jq -c .result c.json

Expected:

{"collections":[{"name":"doku"},{"name":"probe"},{"name":"verteilt"}]}

What you see: the same error text, two different outcomes.

What Message at the time Result after healing
Point 900040 FEHLER timed out stored
Point 900041 FEHLER timed out not stored
Collection probe3 consensus operation commit failed for us created once, not created once

Point 900041 belongs to shard 1 – Drill 7 shows this. Shard 1 has no copy on qdrant-0, and qdrant-0 reached neither of the two copies. The other points fell on shards with a copy in the building itself.

In an earlier run, probe3 was in the list after healing – the proposal was still with the leader and was confirmed as soon as the others could hear it again. Not in this run. So you cannot rely on a failed decision, in either direction.

The copies on all three pods then showed identical counts again (for us shard 0: 4092, shard 1: 4706, shard 2: 4434).

Remember: a timeout means “result unknown”, not “didn’t work”. Without a quorum this applies to decisions too: check whether they exist.

Save your progress? Sign up for free

Drill 7: Dealing with “result unknown”

Where you are: on vdb1, everything connected again.

What you have afterwards: proof that a repeated upsert with the same ID duplicates nothing.

The simplest answer to a timeout: write the same point with the same ID again. An upsert overwrites an existing point instead of creating a second one. Try it – with the point that was lost in Drill 6:

# on vdb1
~/werkbank/bin/python schreiben.py http://10.43.151.237:6333 verteilt 900041 1

Expected:

16:21:36 Punkt 900041: geschrieben

The same command again:

# on vdb1
~/werkbank/bin/python schreiben.py http://10.43.151.237:6333 verteilt 900041 1

Expected:

16:21:39 Punkt 900041: geschrieben
# on vdb1
~/werkbank/bin/python zaehlen.py http://10.43.151.237:6333 verteilt

Expected:

verteilt auf http://10.43.151.237:6333: 13233 Punkte, davon 13 aus Tag 7

What you see: 13 = 3 from Drill 2 + 6 from Drill 3 + 3 from Drill 6 + 900041 – once, although written twice. Which shard the point fell on is shown by qdrant-2:

# on vdb1
curl -s http://10.42.2.6:6333/collections/verteilt/cluster -o v2.json
# on vdb1
jq -c '{peer: .result.peer_id, local: [.result.local_shards[]|{shard_id,points_count,state}]}' v2.json

Expected:

{"peer":1485700002748332,"local":[{"shard_id":0,"points_count":4092,"state":"Active"},{"shard_id":1,"points_count":4707,"state":"Active"}]}

Shard 1 has grown from 4706 to 4707 – 900041 belongs to shard 1, as suspected in Drill 6. If you assign your own point IDs – for example from document and section number – you can simply repeat after a timeout. If you generate IDs randomly, you create a new point with every repetition.

Remember: fixed IDs make repeating safe. On “result unknown” you repeat – or check.

Save your progress? Sign up for free

Diagnosis task: The collection that exists and yet doesn’t

During a network outage, a colleague created a collection. The command aborted after 15 seconds without an answer. The collection is in the list, but:

{"status":{"error":"Service internal error: 0 of 0 read operations failed"},"time":0.006261171}

This is the response to curl -s http://10.42.1.34:6333/collections/probe, recorded in Drill 4 while vdb3 was still cut off. What is going on?

Find the cause before you read on.

Solution, step by step.

  1. Read the shard distribution of the collection: curl -s http://10.42.1.34:6333/collections/probe/cluster -o pr.json, then jq -c '.result | {local: [.local_shards[]|{shard_id,state}], remote: [.remote_shards[]|{shard_id,peer_id,state}]}' pr.json
  2. The response:
{"local":[{"shard_id":0,"state":"Active"},{"shard_id":3,"state":"Active"}],"remote":[{"shard_id":1,"peer_id":1485700002748332,"state":"Initializing"},{"shard_id":2,"peer_id":857928665674298,"state":"Active"},{"shard_id":4,"peer_id":1485700002748332,"state":"Initializing"},{"shard_id":5,"peer_id":857928665674298,"state":"Active"}]}
  1. The majority decided on the collection and distributed its shards across all three peers – including the cut-off one. Shards 1 and 4 are supposed to be created on qdrant-2 and are stuck in Initializing. Each of these shards has only one copy. Every query needs all shards, so every query fails.
  2. After healing in Drill 5, the same query showed all six shards Active, and /collections/probe answered with HTTP 200.

The fix: resolve the partition – then qdrant-2 creates the missing shards. Or delete the collection and create it anew after the outage. The lesson: don’t create or restructure collections during an outage. Decisions that are distributed to all peers get stuck on the one that is missing.

Remember: a collection that exists only as a name is usually a shard waiting for a missing peer. …/cluster shows which one.

Cleanup and checkpoint

The test collection and the test points go.

# on vdb1
curl -s -X DELETE http://10.43.151.237:6333/collections/probe

Expected:

{"result":true,"status":"ok","time":0.111036401}

If probe3 is also in your list, delete it the same way.

# on vdb1
curl -s -X POST 'http://10.43.151.237:6333/collections/verteilt/points/delete?wait=true' -H 'Content-Type: application/json' -d '{"filter":{"must":[{"key":"quelle","match":{"value":"tag07"}}]}}'
  • points/delete with filter deletes all points whose payload matches; wait=true waits until it is done.

Expected:

{"result":{"operation_id":96,"status":"completed"},"status":"ok","time":0.103140407}

Checkpoint:

# on vdb1
~/werkbank/bin/python zaehlen.py http://10.43.151.237:6333 verteilt

Expected:

verteilt auf http://10.43.151.237:6333: 13220 Punkte, davon 0 aus Tag 7
# on vdb1
curl -s http://10.43.151.237:6333/cluster -o k.json
# on vdb1
jq -c '.result | {peers: (.peers|length), role: .raft_info.role, leader: .raft_info.leader, term: .raft_info.term}' k.json

Expected (role depending on which pod answers; leader and term will differ for you – for us the council had meanwhile elected qdrant-2):

{"peers":3,"role":"Follower","leader":1485700002748332,"term":205}
# on vdb2
sudo iptables -S

Expected: no line with 172.16.0. – likewise on vdb3.

# on vdb1
kubectl -n longhorn-system get volumes.longhorn.io -o custom-columns=NAME:.metadata.name,ROBUST:.status.robustness

Expected: all volumes healthy. In an earlier run, one was briefly degraded right after healing – Longhorn also replicates between the nodes and reconciles afterwards. A minute later all were healthy.

Test yourself

  1. How can you tell that a Qdrant peer is cut off, although kubectl get pods shows everything Ready?
  2. Why could the majority in Drill 3 write immediately again after 15 seconds?
  3. Why did no copy become Dead in Drill 6?
  4. A client reports timed out when writing. Is the point stored?
  5. Why did qdrant-2 trigger a new election after healing?
  6. Why should you not create a collection during a network outage?

Answers:

  1. From this peer’s /cluster: role: Candidate, leader: 0 and a term that keeps rising.
  2. Because the majority had set the copy on qdrant-2 to Dead by decision. After that, nobody waits for its confirmation anymore.
  3. Locking a copy is a Raft decision. Without a quorum there are no decisions.
  4. Unknown. We measured both: 900010 and 900040 were stored, 900041 was not – its shard had no reachable copy. Check, or repeat with the same ID.
  5. Because its term, through the many unsuccessful applications, was higher than the leader’s. In Raft, a higher term forces a new election.
  6. Because the decision also distributes shards to the missing peer. The collection is then in the list, but answers no query until the peer is back.

Interview note

“What happens in a three-node Qdrant cluster during a network partition?” – The side with the majority keeps the Raft leader, sets the unreachable copies to Dead and keeps writing. The minority becomes a candidate, accepts no decisions and, for us, no write or search requests either, but stays Ready for Kubernetes and keeps receiving traffic from the Service. After healing, the Dead copies reconcile the missed points. Without any majority there are no more decisions; reads only work where a complete copy is local. Important for clients: a timeout means “result unknown”; fixed point IDs make repeating safe.

Enterprise note

Partitions are rarely whole nodes, but often individual switch ports, MTU problems or overloaded links. That is why you monitor the Raft state of each peer (role, term, commit) and raise an alert if a peer is Candidate for longer than a minute or the term rises quickly (Day 11). Clients write with fixed IDs derived from the source data and retry on timeouts with backoff. Schema changes – new collections, resharding, replica moves – only run when all peers are Active; a pipeline checks this beforehand via …/cluster. And because a readiness probe does not see the partition, a synthetic read check per pod belongs in monitoring.

Summary

  • iptables DROP on the node IPs separates Qdrant peers while all pods stay Ready.
  • One peer cut off: the majority kept the leader and term 113, the minority became a candidate (term up to 172 in three minutes). After about 15 seconds the majority set the copy of shard 1 on qdrant-2 to Dead and then kept writing immediately. The minority rejected decisions and answered neither writes nor searches.
  • Three points reported timed out and were stored anyway. The three points through the minority never arrived.
  • After healing: new election (term 174), commit 86 → 106, the Dead copy Active again within ten seconds, identical point counts on both copies.
  • Without a majority: qdrant-0 nominally remained Leader, decisions failed, no copy became Dead. Reading only worked with a complete local copy. Of two timeouts, one was stored and one was not; a collection with an error message was created after all after healing in one of two runs.
  • A repeated upsert with the same ID duplicates nothing.

Commands at a glance

Command Purpose
curl -s http://<pod-ip>:6333/cluster -o k.json fetch the Raft view of a single peer
jq -c '.result.raft_info \| {role, leader, term, commit}' k.json read role, leader, term, commit
curl -s http://<pod-ip>:6333/collections/<name>/cluster -o v.json fetch shard distribution and copy states
sudo iptables -I INPUT -s <ip> -j DROP drop incoming packets from a node
sudo iptables -I OUTPUT -d <ip> -j DROP drop outgoing packets to a node
sudo iptables -D INPUT -s <ip> -j DROP remove exactly this rule again
sudo iptables -L INPUT -n --line-numbers show rules with numbers
~/werkbank/bin/python schreiben.py <url> <collection> <start> <count> write test points individually
~/werkbank/bin/python zaehlen.py <url> <collection> count points and test points
curl -s -X POST <url>/collections/<name>/points -d '{"ids":[…]}' -o p.json look up specific points
curl -s -X POST '<url>/collections/<name>/points/delete?wait=true' -d '{"filter":…}' delete points by filter

Contents

More