vmware / vmware/splinterdb

How to handle a failed iterator_init()?

Open
#59 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
732
Forks
67
PR merge metrics
No merged PRs in 30d

Description

If I call an "init" function and get an error code, I usually expect that the init function has cleaned itself up, and I don't need to call de-init on any state that remains.

In splinter_range I see the opposite, where a failed splinter_range_iterator_init() leads to splinter_range_iterator_deinit() being called.

The code is a bit complex and I haven't dug in, so I can't tell if this is a bug or just unconventional.

In the implementation of kvstore_iterator_init() in #58, I'm assuming the latter, and hiding the complexity from the kvstore user by calling deinit for them on a failed init.

It'd be good to investigate, fix if necessary, and document the correct semantics in code comments.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with splinter.c around splinter_range_iterator_init() at lines 6858-6859, then compare the failed-init handling with kvstore_iterator_init() from #58. Determine whether callers must deinitialize state after a failed init, fix the behavior if needed, and document the correct semantics in code comments.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.