mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-10 15:02:56 +00:00
storage controller: include stripe size in compute notifications (#6974)
## Problem - The storage controller is the source of truth for a tenant's stripe size, but doesn't currently have a way to propagate that to compute: we're just using the default stripe size everywhere. Closes: https://github.com/neondatabase/neon/issues/6903 ## Summary of changes - Include stripe size in `ComputeHookNotifyRequest` - Include stripe size in `LocationConfigResponse` The stripe size is optional: it will only be advertised for multi-sharded tenants. This enables the controller to defer the choice of stripe size until we split a tenant for the first time.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import time
|
||||
from collections import defaultdict
|
||||
from datetime import datetime, timezone
|
||||
from typing import Any, Dict, List
|
||||
from typing import Any, Dict, List, Union
|
||||
|
||||
import pytest
|
||||
from fixtures.log_helper import log
|
||||
@@ -443,10 +443,12 @@ def test_sharding_service_compute_hook(
|
||||
|
||||
# Initial notification from tenant creation
|
||||
assert len(notifications) == 1
|
||||
expect = {
|
||||
expect: Dict[str, Union[List[Dict[str, int]], str, None, int]] = {
|
||||
"tenant_id": str(env.initial_tenant),
|
||||
"stripe_size": None,
|
||||
"shards": [{"node_id": int(env.pageservers[0].id), "shard_number": 0}],
|
||||
}
|
||||
assert notifications[0] == expect
|
||||
|
||||
env.attachment_service.node_configure(env.pageservers[0].id, {"availability": "Offline"})
|
||||
|
||||
@@ -460,6 +462,7 @@ def test_sharding_service_compute_hook(
|
||||
log.info(f"notifications: {notifications}")
|
||||
expect = {
|
||||
"tenant_id": str(env.initial_tenant),
|
||||
"stripe_size": None,
|
||||
"shards": [{"node_id": int(env.pageservers[1].id), "shard_number": 0}],
|
||||
}
|
||||
|
||||
@@ -475,10 +478,27 @@ def test_sharding_service_compute_hook(
|
||||
|
||||
def received_restart_notification():
|
||||
assert len(notifications) == 3
|
||||
assert notifications[1] == expect
|
||||
assert notifications[2] == expect
|
||||
|
||||
wait_until(10, 1, received_restart_notification)
|
||||
|
||||
# Splitting a tenant should cause its stripe size to become visible in the compute notification
|
||||
env.attachment_service.tenant_shard_split(env.initial_tenant, shard_count=2)
|
||||
expect = {
|
||||
"tenant_id": str(env.initial_tenant),
|
||||
"stripe_size": 32768,
|
||||
"shards": [
|
||||
{"node_id": int(env.pageservers[1].id), "shard_number": 0},
|
||||
{"node_id": int(env.pageservers[1].id), "shard_number": 1},
|
||||
],
|
||||
}
|
||||
|
||||
def received_split_notification():
|
||||
assert len(notifications) == 4
|
||||
assert notifications[3] == expect
|
||||
|
||||
wait_until(10, 1, received_split_notification)
|
||||
|
||||
env.attachment_service.consistency_check()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user