Skip to content

nameserver: refuse to delete one a live zone lists - #102

Open
aberoham wants to merge 1 commit into
NicTool:mainfrom
aberoham:nameserver-in-use
Open

aberoham wants to merge 1 commit into
NicTool:mainfrom
aberoham:nameserver-in-use

Conversation

@aberoham

Copy link
Copy Markdown
Contributor

On main, mysql, json and toml answered 200 to DELETE /nameserver/{id} while a live zone listed it. PUT /nameserver/{id} with {"deleted": true} did the same, and GET /zone/{id}/ns then answered empty. POST /zone and PUT /zone/{id} accepted deleted or nonexistent nameserver ids, and PUT {"deleted": false} restored zones listing deleted nameservers.

DELETE and PUT with deleted true now answer 409 "nameserver N still serves a live zone". Soft-deleted zones do not count. Zone create, writes to a zone's nameserver set, and restore now answer 400 "nameserver N is deleted or does not exist". A create that omits nameservers now skips the group's deleted ones inside the store, so a concurrent delete cannot cause a 400.

On mysql, zone writes take LOCK IN SHARE MODE on nameserver rows before any plain read. A nameserver delete locks its row FOR UPDATE, then checks live zones, so only one wins. Locking first avoids ER_CHECKREAD on MariaDB 11 after a post-snapshot row change. On json and toml, both share one serialize key, like permission create.

A mysql race test runs zone create and nameserver delete concurrently. One wins. The loser fails with STORE_INVALID or STORE_CONFLICT. Without the share lock it fails every run. The existing nameserversFor zone test now asserts the store refuses a deleted nameserver.

DELETE /nameserver/{id} soft-deleted a nameserver that live zones still
listed, which left those zones with an empty NS set. It now answers 409
while any live zone lists it, and so does a PUT that sets deleted.

Zone writes hold the other half of the rule. Create, a write of the
nameserver set, and a restore answer 400 for a deleted or missing
nameserver. A new zone's default set skips the group's usable
nameservers that are deleted. On mysql the zone write takes a share lock
on the nameserver rows and the delete locks its own row, so only one of
them can win. The zone write takes those locks before any plain read,
since MariaDB refuses a locking read of a row changed after the snapshot.
The file stores run both under one serialize key.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant