Commit Graph
249 Commits
Author SHA1 Message Date
Elle Mouton c1ba7a97a8 graph/db: increase default page size 2025-07-31 07:19:15 +02:00
Elle Mouton a6b077064f graph/db: use batch loading for ForEachChannel 2025-07-31 07:19:15 +02:00
Elle Mouton d5da637a38 graph/db: remove unused param 2025-07-31 07:19:14 +02:00
Elle Mouton f39edae6e3 graph/db: use new batch helpers for edge loading
Use the new batch helpers to replace the existing logic for loading an
edge.
2025-07-31 07:19:14 +02:00
Elle Mouton 8ad5f633bc sqldb: add channel data batch queries
Also add the calling logic for these queries. This logic is not yet
used.
2025-07-31 07:19:14 +02:00
Elle Mouton 36eb0e3ff6 graph/db: use batch loading for NodeUpdatesInHorizon 2025-07-30 19:29:22 +02:00
Elle Mouton c8c86717f2 graph/db: add NodeUpdatesInHorizon benchmark 2025-07-30 19:29:22 +02:00
Elle Mouton 84b1670742 graph/db: use batch loading for ForEachNode 2025-07-30 19:29:22 +02:00
Elle Mouton d05b918c7a graph/db: refactor buildNode to use batch fetching
Here, we add a new `buildNodeWithBatchData` helper method that can be
used to construct a `models.LightningNode` object using pre-fetched
batch data. The existing `buildNode` method is then adjusted to use this
new helper.
2025-07-30 19:29:22 +02:00
Elle Mouton 0dc0d320f8 graph/db+sqldb: queries and logic for batch fetching node data
In this commit, we add the queries that will be needed to batch-fetch
the data of a set of nodes. The logic for using these new queries is
also added but not used yet.
2025-07-30 19:29:21 +02:00
Elle Mouton 5a1184c664 graph/db+sqldb: remove LEFT JOIN for fetching node addresses
In this commit, we remove the LEFT JOIN query that was used for fetching
a nodes addresses. The reason it was used before was to ensure that we'd
get an empty address list if the node did exist but had no addresses.
This was for the purposes of the `AddrsForNode` method since it needs to
return false/true to indicate if the given node exists.
2025-07-30 18:11:01 +02:00
Elle Mouton 43db6683d2 graph/db+sqldb: only fetch what is needed for graph cache
Add a ListChannelsWithPoliciesForCachePaginated query that only fetches
the channel/policy fields that the cache requires.
2025-07-30 18:11:01 +02:00
Elle Mouton 5800a3e054 graph/db: benchmark various graph read calls
This commit adds benchmark tests for the ForEachNode and ForEachChannel
DB calls which are called by DescribeGraph.
2025-07-30 14:06:33 +02:00
Elle Mouton f5ce4a5656 graph/db: add BenchmarkCacheLoading
Add a benchmark test to test graph cache loading against various local
graph DBs.
2025-07-30 14:06:33 +02:00
Elle Mouton 45033b8c54 graph/db: add SQL migration progress logs 2025-07-30 14:06:33 +02:00
Elle Mouton 77fe1816f6 graph/db: add test helper for populating via migration
This commit adds a helper test that is similar to TestPopulateDBs except
for the fact that it uses the MigrateGraphToSQL function directly to
migrate a local kvdb-sql graph to a native SQL one.
2025-07-30 14:06:33 +02:00
Elle Mouton afbe6b12ed graph/db: define various db connection helpers for incoming tests
This is a prep commit that just adds all the boilerplate connection
logic for connecting to various graph DBs. These will be used in
upcoming commits which will add tests and benchmarks.
2025-07-30 14:06:33 +02:00
Elle Mouton 240966de90 graph/db+log: use v2 logger for graph subsystem 2025-07-29 11:34:47 +02:00
Elle Mouton 858c064ca2 graph/db: fix potential nil pointer derefs
Here, we fix two bugs that could lead to a nil pointer dereference.
Both are caused by refering to policies that may be nil at the
call-site.
2025-07-28 14:39:28 +02:00
Elle Mouton ddc0e95eda graph/db+sqldb: delete channels in batches
Use the new `SLICES` directive to add a DeleteChannels query which takes
a set of DB channel IDs. Then replace all our calls to DeleteChannel
with a paginated call to DeleteChannels.
2025-07-22 17:17:23 +02:00
Elle Mouton de6c030f29 graph/db: let DeleteChannelEdges use new wrapped SQL call
Update it to use the new wrapped version of
GetChannelsBySCIDWithPolicies to reduce the number of DB calls.
2025-07-22 17:17:13 +02:00
Elle Mouton e269d57ffa sqldb+graph/db: use pagination for FetchChanInfos 2025-07-22 17:17:11 +02:00
Elle Mouton 88e9a21d63 sqldb+graph/db: update FilterKnownChanIDs to use pagination
Remove a TODO by making use of the new sqldb.ExecutePagedQuery to fetch
channels in batches rather than one by one.
2025-07-22 17:16:59 +02:00
Elle Mouton f72c48b283 graph/db+sqldb: pass set of outpoints to SQL
This commit adds a new GetChannelsByOutpoints query which takes a slice
of outpoint strings. This lets us then update PruneGraph to use
paginated calls to GetChannelsByOutpoints instead of making one DB call
per outpoint.
2025-07-22 17:16:49 +02:00
Elle Mouton 2fa30e8735 graph+config: add sql pagination config to ChannelGraph 2025-07-22 17:16:41 +02:00
Olaoluwa Osuntokun 9059a4e7ba Merge pull request #10080 from ellemouton/graphPrefixTables
sqldb+graph/db: prefix graph SQL objects with "graph_"
2025-07-15 15:21:02 -07:00
Elle Mouton 74b70a5108 sqldb+graph/db: prefix graph SQL objects with "graph_"
This makes it more clear what each table is for especially when viewed
with other invoice/payments tables.
2025-07-15 18:40:16 +02:00
Elle Mouton d7b8259a36 graph/db: add graph SQL migration rapid unit test 2025-07-15 18:17:23 +02:00
Elle Mouton 955f4c9182 graph/db: refactor to make postgres fixtures re-usable
In preparation for tests where we will want to spin up SQL DBs many
times, we do some refactoring so that it is easy to re-use postgres
fixtures since those are expensive to spin up.
2025-07-15 18:06:05 +02:00
Elle Mouton 83f6dc4983 multi: reset for ForEachNodeDirectedChannel 2025-07-15 11:25:10 +02:00
Elle Mouton 13d0bd5ef6 graph/db: let ForEachChannelCacheable take a reset param 2025-07-15 11:25:10 +02:00
Elle Mouton b3f3766fe6 multi: pass reset to GraphSession 2025-07-15 11:25:09 +02:00
Elle Mouton e17fd58a1d graph/db: pass reset to ForEachNodeCacheable 2025-07-15 11:25:09 +02:00
Elle Mouton 21ac7ef6f4 multi: add reset to ForEachNode 2025-07-15 11:25:09 +02:00
Elle Mouton c32bf642d2 multi: pass reset to ForEachNodeCached 2025-07-15 11:23:27 +02:00
Elle Mouton e5fbca8299 multi: let ForEachNodeChannel take a reset param 2025-07-15 11:23:27 +02:00
Elle Mouton 16126d7703 graph/db: expose reset in ForEachSourceNodeChannel 2025-07-15 11:23:27 +02:00
Elle Mouton 88261834e5 graph/db: expose reset in ForEachChannel
Add a `reset` call-back param to the V1Store ForEachChannel method.
2025-07-15 11:23:26 +02:00
Elle Mouton e00f0a03fc graph/db: prep SQLStore for reset param
This commit just surfaces the locations in the SQLStore where we will
later pass reset params through.
2025-07-15 11:23:26 +02:00
Elle Mouton 57d4ce0f9b graph/db: expose KVStore locations where a reset is needed
This commit passes no-op reset callbacks to various places where they
are needed in the KVStore. Upcoming commits will replace the no-ops by
adding reset params to the methods that require it.
2025-07-15 11:23:26 +02:00
Elle Mouton 8b82a5c8fe graph/db: migrate zombie index to SQL
This commit expands `MigrateGraphToSQL` to include migration of the
zombie index.

NOTE: we take this opportunity to clean up the zombie index a bit by
first checking for each channel in the zombie index if it has been
marked as closed in the closed-scid index. If it has, then there is no
need to include it in the zombie index. A special case test for this
is added too.
2025-07-11 09:36:17 +02:00
Elle Mouton 0cb17bbbe5 graph/db: migrate closed SCID index
This commit expands `MigrateGraphToSQL` to include the migration of the
closed-scid index.
2025-07-11 09:36:14 +02:00
Elle Mouton 03ede9ccef graph/db: migrate prune log
This commit expands the `MigrateGraphToSQL` to include migration of the
prune log.
2025-07-11 09:15:47 +02:00
Elle Mouton 36f8a66b5a graph/db: remove temporary test skip
The skip is no longer needed.
2025-07-10 14:54:04 +02:00
Elle Mouton b7d4f80e3e graph/db: pass in ctx to test method
Fix compilation error.
2025-07-10 14:53:10 +02:00
Oliver Gugger 8ee661f18f Merge pull request #10043 from ellemouton/ctx3
multi: add context.Context param to more graphdb.V1Store methods
2025-07-10 13:40:51 +02:00
Elle Mouton b58089049a graph/db: migrate channels and polices to SQL
In this commit, the `MigrateGraphToSQL` function is expanded to migrate
the channel and channe policy data. Both of these have the special case
where the kvdb store records may contain invalid TLV. If we encounter a
channel with invalid TLV, we skip it and its policies. If we encounter a
policy with invalid TLV, we skip it.

The `TestMigrateGraphToSQL` and `TestMigrationWithChannelDB` tests are
updated accordingly.
2025-07-09 10:18:57 +02:00
Elle Mouton 3d5e852c8c graph/db: let ForEachNodeCached take a context 2025-07-08 15:11:02 +02:00
Elle Mouton 1e804a3d5f graph/db: let ForEachNode take a context 2025-07-08 15:11:02 +02:00
Elle Mouton f05ef2db97 graph/db: let ForEachNodeCacheable take a context 2025-07-08 15:10:30 +02:00