Skip to content

Manage indexing jobs with a queue - #782

Merged
zonotope merged 69 commits into
mainfrom
feature/index-queue
May 29, 2024
Merged

zonotope merged 69 commits into
mainfrom
feature/index-queue

Conversation

@zonotope

Copy link
Copy Markdown
Contributor

This patch schedules indexing jobs for new commits with a dropping queue to ensure we are always working on the latest commit. It also separates commit updates to ledger/branch state from index updates to simplify and streamline those updates, and all of these updates and decisions about when/if to make them are executed entirely within an atomic swap! to branch state to eliminate race conditions.

In order to enable atomic updates to index state, new dbs are loaded in the background within an AsyncDB. To enable interoperability between AsyncDB and JsonLdDb, I had to add more protocols for history queries, policy restriction, and time travel.

I also added a new indexing protocol for db record types that replaces the standalone indexer records and iIndex protocols. With this patch, all index and commit updates to ledger state are atomic and without any locks.

There is still a lot of cleanup and reorganization to do, but this patch is the minimal changeset necessary to manage indexing jobs with a queue.

zonotope added 30 commits May 21, 2024 13:00
This option was never set.
Generating a commit from a db is the purview of the db itself, so that code
should live in the db namespace hierarchy to avoid cyclic dependencies down the
line. This should probably be a protocol, but I'm punting on that for now
because I don't think defining this particular protocol is necessary to get the
index queue defined
The remaining functions in this namespace are the responsibility of the ledger,
so they should be under the ledger namespace hierarchy to avoid cyclic dependencies.
@zonotope
zonotope requested a review from a team May 28, 2024 08:36
returns a db with an updated :commit."
[{:keys [alias conn] :as ledger} {:keys [t stats commit] :as db} opts]
(go-try
(let [{:keys [did message tag file-data? index-files-ch] :as opts*}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does anything actually supply an index-files-ch opt yet? Is that something that server will supply?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, a nitpick: index-files-ch may be a slight misnomer if the FileStore isn't being used. Maybe index-node-ch?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fluree/server supplies it, and it is used to distributed the index file notifications across the network.

(go)))


TimeTravel

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm liking these new protocols a lot. This looks like a nice step towards decomplecting : )

zonotope added 3 commits May 28, 2024 15:33
This is kind of a hack to give the test access to the underlying db's stats. I
am hesitant to add a top level api/protocol for db stats because different dbs
will necessarily have different stats, so they probably won't be interchangeable.
Simple subject crawl doesn't currently work for every type of db we now support.
We're disabling this optimization for now, but we'll be able to bring it back in
the context of a general query planning/optimization framework.

@dpetran dpetran left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Base automatically changed from feature/async-db-record to main May 29, 2024 03:50
@zonotope
zonotope merged commit 448c013 into main May 29, 2024
@zonotope
zonotope deleted the feature/index-queue branch May 29, 2024 03:50
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.

3 participants