mirror of
https://github.com/neondatabase/neon.git
synced 2026-06-03 05:20:38 +00:00
refactor(timeline_detach_ancestor): replace ordered reparented with a hashset (#8629)
Earlier I was thinking we'd need a (ancestor_lsn, timeline_id) ordered list of reparented. Turns out we did not need it at all. Replace it with an unordered hashset. Additionally refactor the reparented direct children query out, it will later be used from more places. Split off from #8430. Cc: #6994
This commit is contained in:
committed by
John Spray
parent
658d763915
commit
40e3c913bb
@@ -857,7 +857,7 @@ class PageserverHttpClient(requests.Session, MetricsGetter):
|
||||
timeline_id: TimelineId,
|
||||
batch_size: int | None = None,
|
||||
**kwargs,
|
||||
) -> List[TimelineId]:
|
||||
) -> Set[TimelineId]:
|
||||
params = {}
|
||||
if batch_size is not None:
|
||||
params["batch_size"] = batch_size
|
||||
@@ -868,7 +868,7 @@ class PageserverHttpClient(requests.Session, MetricsGetter):
|
||||
)
|
||||
self.verbose_error(res)
|
||||
json = res.json()
|
||||
return list(map(TimelineId, json["reparented_timelines"]))
|
||||
return set(map(TimelineId, json["reparented_timelines"]))
|
||||
|
||||
def evict_layer(
|
||||
self, tenant_id: Union[TenantId, TenantShardId], timeline_id: TimelineId, layer_name: str
|
||||
|
||||
@@ -165,7 +165,7 @@ def test_ancestor_detach_branched_from(
|
||||
)
|
||||
|
||||
all_reparented = client.detach_ancestor(env.initial_tenant, timeline_id)
|
||||
assert all_reparented == []
|
||||
assert all_reparented == set()
|
||||
|
||||
if restart_after:
|
||||
env.pageserver.stop()
|
||||
@@ -534,7 +534,7 @@ def test_compaction_induced_by_detaches_in_history(
|
||||
|
||||
for _, timeline_id in skip_main:
|
||||
reparented = client.detach_ancestor(env.initial_tenant, timeline_id)
|
||||
assert reparented == [], "we have no earlier branches at any level"
|
||||
assert reparented == set(), "we have no earlier branches at any level"
|
||||
|
||||
post_detach_l0s = list(filter(lambda x: x.l0, delta_layers(branch_timeline_id)))
|
||||
assert len(post_detach_l0s) == 5, "should had inherited 4 L0s, have 5 in total"
|
||||
@@ -774,7 +774,7 @@ def test_sharded_timeline_detach_ancestor(neon_env_builder: NeonEnvBuilder):
|
||||
else:
|
||||
break
|
||||
|
||||
assert reparented == [], "too many retries (None) or unexpected reparentings"
|
||||
assert reparented == set(), "too many retries (None) or unexpected reparentings"
|
||||
|
||||
for shard_info in shards:
|
||||
node_id = int(shard_info["node_id"])
|
||||
|
||||
Reference in New Issue
Block a user