Subject: Re: [PATCH v2 00/17] odb: make object database sources pluggable

From: Patrick Steinhardt <[email-masked]>
Date: Tue, 10 Mar 2026 13:19:52 +0100

On Thu, Mar 05, 2026 at 12:42:19PM -0800, Junio C Hamano wrote:
> Patrick Steinhardt <[email-masked]> writes:
> 
> > To set expectations: this is only a start, there is still functionality
> > missing that needs to be made pluggable. Most importantly:
> >
> >   - Counting of objects.
> >
> >   - Abbreviating object IDs and finding ambiguous objects.
> >
> >   - Consistency checks.
> >
> >   - Optimizing the object database.
> >
> >   - Generating packfiles.
> >
> > These will all happen in later patch series. That being said, with this
> > patch series one already gets a lot of the basic functionality, and it's
> > almost possible to do local workflows. Only "almost" though because we
> > rely on abbreviating object IDs in a lot of places, but once that part
> > is implemented in a subsequent patch series you can indeed work locally
> > with an alternate backend.
> 
> I've been looking over this series, and the transition to a pluggable
> interface for ODB sources is very clean and follows the patterns we've
> established for refs and streams quite well.
> 
> One thing I am puzzled on the design, specifically starting with
> patch 09 and onward, is the lack of documentation regarding which of
> the new callbacks in `struct odb_source` are mandatory and which are
> optional.

That's mostly explained by the fact that all of them are mandatory for
now. :)

> In `odb/source.h`, the static inline wrapper functions dereference the
> backend's function pointers directly. For example:
> 
> +static inline int odb_source_read_object_info(struct odb_source *source,
> +					      const struct object_id *oid,
> +					      struct object_info *oi,
> +					      enum object_info_flags flags)
> +{
> +	return source->read_object_info(source, oid, oi, flags);
> +}
> 
> If a future backend (say, a read-only network proxy) doesn't implement
> some of the write-related functions or the iteration functions, the
> current wrappers will cause a segmentation fault.
> 
> Do we want to
> 
>   - Document in `struct odb_source` which callbacks must be implemented
>     by every backend.
> 
>   - Have the wrapper functions check for NULL. If a mandatory function
>     is missing, a `BUG()` would be appropriate. If it's truly optional,
>     the wrapper could return a suitable error code (like -1 or
>     `GIT_ENOTSUP`).
> 
> Given that the "files" backend implements the full set, it's easy to
> miss, but as we add more specialized backends, a clearly defined
> interface contract may become important.
> 
> What are your thoughts on which of these should be considered the
> "minimal viable" set for an ODB source?

I guess this'll become more interesting once we have additional ODB
sources -- and that'll likely happen sooner rather than later. I've got
a couple of patch series pending that'll convert our existing sources
that we've already got into "proper" sources. And with those it may make
sense to document this better.

I see that this series already got merged to "next", but I'll keep it in
mind going forward that we'll want to eventually do this.

Thanks!

Patrick