Skip to content

Commit f672b46

Browse files
committed
fix(picodata): join through one peer per machine; let HAProxy list every instance
- an instance per vCPU on four 32-vCPU machines is 128 instances: the peer list (64 at most) and the HAProxy backend (64 at most) refused the cluster. Peers are now the first instance of each machine, enough to join; the HAProxy schema takes up to 1024 servers
1 parent 2700583 commit f672b46

6 files changed

Lines changed: 39 additions & 9 deletions

File tree

‎internal/domain/compile/recipe_picodata.go‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,14 @@ func picodataRecipe(c *compilation) error {
123123
Role: role, Kind: spec.HostPrepScript,
124124
Content: "install -d -m 0750 -o 1000 -g 1000 " + strings.Join(dirs, " ") + "\n",
125125
})
126-
peers := make([]any, 0, len(instances))
126+
// The peers an instance joins through: the first instance of every
127+
// machine. Joining needs one live peer, and the config takes at most 64
128+
// (a machine full of instances per vCPU outnumbers that).
129+
peers := make([]any, 0, len(nodes))
127130
for _, in := range instances {
128-
peers = append(peers, fmt.Sprintf("%s:%d", ip(in.machine), in.iproto()))
131+
if in.slot == 0 {
132+
peers = append(peers, fmt.Sprintf("%s:%d", ip(in.machine), in.iproto()))
133+
}
129134
}
130135
tierValues := make([]any, 0, len(tiers))
131136
for _, t := range tiers {

‎internal/domain/compile/tune_picodata_test.go‎

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,12 @@ func TestPicodataInstancesPerMachine(t *testing.T) {
360360
if !strings.Contains(conf, " failure_domain: {host: "+c.Machine+"}\n") {
361361
t.Fatalf("%s: no failure domain:\n%s", c.Name, conf)
362362
}
363-
if strings.Count(conf, "${ip:db-") < tc.instances {
364-
t.Fatalf("%s: peers miss instances:\n%s", c.Name, conf)
363+
// The peers are the first instance of every machine: enough
364+
// to join, and within the config's 64.
365+
// Beside the peers the config names the instance's own two
366+
// advertise addresses (iproto, pgproto).
367+
if peers := strings.Count(conf, "${ip:db-") - 2; peers != tc.machines {
368+
t.Fatalf("%s: %d peer addresses, want one per machine (%d):\n%s", c.Name, peers, tc.machines, conf)
365369
}
366370
if c.Mounts[0].Source == "/data/picodata" || names[c.Mounts[0].Source+c.Machine] {
367371
t.Fatalf("%s: shared instance directory %s", c.Name, c.Mounts[0].Source)
@@ -445,3 +449,20 @@ func TestPicodataRefusesDataBeyondMemtx(t *testing.T) {
445449
})
446450
}
447451
}
452+
453+
// An instance per vCPU on four XL machines is 128 instances, twice the 64
454+
// peers the config takes: the peers are the first instance of each machine
455+
// (TPC-C 1000 WH on Picodata, 4 nodes, RF 2, was refused by the schema).
456+
func TestPicodataPeersStayWithinTheConfig(t *testing.T) {
457+
t.Parallel()
458+
c := picoCase("26.2", map[string]any{"instances_per_machine": 0, "haproxy": 1, "pgproto": true, "tiers": picoTiers(4, 2, nil)})
459+
c.size = "XL"
460+
out, _ := compileTuned(t, c)
461+
cs := picoContainers(out)
462+
if len(cs) != 128 {
463+
t.Fatalf("%d instances, want 128", len(cs))
464+
}
465+
if peers := strings.Count(fileOf(out, cs[0].Name, picoConf), "${ip:db-") - 2; peers != 4 {
466+
t.Fatalf("%d peers, want one per machine (4)", peers)
467+
}
468+
}

‎pipelines/live/tests/platform/contracts/contract.lock.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"pipelines/schemas/testdata/cfg.exporter.mysqld@1.json": "203e8c846af0c2e437698ca4f9e512ffa7f1770f9ad2b99234b14dc941d49ab4",
1515
"pipelines/schemas/testdata/cfg.exporter.node@1.json": "9424f6c447e40138964cf2bd7c1f7deb5773c96760beec5c6e2996c62e41ba9a",
1616
"pipelines/schemas/testdata/cfg.exporter.postgres@1.json": "26437ce2820f43de483b948f2d60973aece499413f2aa4923fbd58a9caf24143",
17-
"pipelines/schemas/testdata/cfg.haproxy.cfg@2.json": "5ab63c2f58bc7972c68e2065f986f85c48eef9ea25309cb252059d83de7435a2",
17+
"pipelines/schemas/testdata/cfg.haproxy.cfg@2.json": "361ab578f8d8959a229436053facce0314f9cc6c616eefa07cd6b1ee1f4a50d0",
1818
"pipelines/schemas/testdata/cfg.host.disks@1.json": "1dc63269f7f9bb3867a2e51356cca9599c3e7840fba199083466021f6b777f1a",
1919
"pipelines/schemas/testdata/cfg.host.sysctl@1.json": "9c0d17049588a8b5a8082f0b212478b43b8b829f6a2dc31dba41c05ad808bd30",
2020
"pipelines/schemas/testdata/cfg.mariadb.cnf@10.11.json": "e76f40b803c0c40fa81b8f04a1d674db89572c19a470f9d5ea0f92157330cf3f",
@@ -111,7 +111,7 @@
111111
"web/src/schemas/cfg.exporter.node_v1.ts": "0cbe59f2c48e8747ac3af8f58ed15ddc0af2c63e64d0d5e311db6de72221bca3",
112112
"web/src/schemas/cfg.exporter.postgres_v1.json": "26437ce2820f43de483b948f2d60973aece499413f2aa4923fbd58a9caf24143",
113113
"web/src/schemas/cfg.exporter.postgres_v1.ts": "d4268027bd5829043b77af7669f6cc6cd509c0231b5020bb0e38a6703c02ec3e",
114-
"web/src/schemas/cfg.haproxy.cfg_v2.json": "5ab63c2f58bc7972c68e2065f986f85c48eef9ea25309cb252059d83de7435a2",
114+
"web/src/schemas/cfg.haproxy.cfg_v2.json": "361ab578f8d8959a229436053facce0314f9cc6c616eefa07cd6b1ee1f4a50d0",
115115
"web/src/schemas/cfg.haproxy.cfg_v2.ts": "8d1b3e842c3863161beaebed94d6479fe9ff61f445258a3a913a02b8a55859d8",
116116
"web/src/schemas/cfg.host.disks_v1.json": "1dc63269f7f9bb3867a2e51356cca9599c3e7840fba199083466021f6b777f1a",
117117
"web/src/schemas/cfg.host.disks_v1.ts": "ac049337cb1ccde220b73e3759ed1039a89f4f41cb1980269e6b66d615eeac80",

‎pipelines/schemas/cfg/haproxy_cfg.go‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,11 @@ func Haproxy2() *schemapb.Schema {
157157
Desc("server maxconn: per-backend connection ceiling; 0 leaves it unlimited.").
158158
Gte(0).Lte(1000000).Default(0),
159159
).Strict(),
160-
).Title("Servers").Group("Listeners").MinItems(1).MaxItems(64).Required(),
160+
// A Picodata cluster with an instance per vCPU puts every
161+
// instance behind the listener (128 on four 32-vCPU machines);
162+
// HAProxy itself sets no small bound on a backend's servers.
163+
// doc: https://docs.haproxy.org/2.9/configuration.html#4-server
164+
).Title("Servers").Group("Listeners").MinItems(1).MaxItems(1024).Required(),
161165
).Strict(),
162166
).Title("Listeners").Group("Cluster").
163167
Desc("One frontend/backend pair per access path (rw, ro, ...). Filled by the server from topology.").

‎pipelines/schemas/testdata/cfg.haproxy.cfg@2.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@
494494
}
495495
}
496496
],
497-
"maxItems": "64",
497+
"maxItems": "1024",
498498
"minItems": "1"
499499
},
500500
"name": "servers",

‎web/src/schemas/cfg.haproxy.cfg_v2.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@
494494
}
495495
}
496496
],
497-
"maxItems": "64",
497+
"maxItems": "1024",
498498
"minItems": "1"
499499
},
500500
"name": "servers",

0 commit comments

Comments
 (0)