Skip to content
This repository has been archived by the owner on Oct 7, 2023. It is now read-only.

Commit

Permalink
zketcd: support deleting directories left empty by ephemeral nodes
Browse files Browse the repository at this point in the history
Ephemeral node deletion doesn't update the CVersion, so the directory
will seem to have children when it doesn't after losing ephemeral nodes.

Note: this fails cross-checking and etcd likely needs an API extension
to get full zk compatibility.

Fixes #88
  • Loading branch information
heyitsanthony committed Nov 8, 2017
1 parent c0202ca commit 951d224
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions zketcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,15 @@ func (z *zkEtcd) mkDeleteTxnOp(op *DeleteRequest) opBundle {
}
}

crev := s.Rev(mkPathCVer(p))
// Force CVer into read-set to catch any conflicting update
// which would invalidate emptiness check.
s.Rev(mkPathCVer(p))
// Check if directory has any children.
gresp, gerr := z.c.Get(z.c.Ctx(), getListPfx(p),
// TODO: monotonic revisions from serializable
// etcd.WithSerializable(),
etcd.WithPrefix(),
etcd.WithCountOnly(),
etcd.WithRev(crev),
etcd.WithLimit(1))
if gerr != nil {
return gerr
Expand Down

0 comments on commit 951d224

Please sign in to comment.