mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-27 14:11:04 +02:00
multi: itest jobs with SQL graph backend
In this commit, a new `test_native_sql` build flag is defined. If this build flag is used along with the `--use-native-sql` config option, then the SQLStore implementation of the graphdb.V1Store will be initialised. This is then used to run our itest suite against the new SQLStore graph implementation. NOTE that this only works for new nodes currently - the migration from kv-to-sql is yet to be implemeneted.
This commit is contained in:
@@ -1046,23 +1046,6 @@ func (d *DefaultDatabaseBuilder) BuildDatabase(
|
||||
)
|
||||
}
|
||||
|
||||
graphStore, err := graphdb.NewKVStore(
|
||||
databaseBackends.GraphDB, graphDBOptions...,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
dbs.GraphDB, err = graphdb.NewChannelGraph(graphStore, chanGraphOpts...)
|
||||
if err != nil {
|
||||
cleanUp()
|
||||
|
||||
err = fmt.Errorf("unable to open graph DB: %w", err)
|
||||
d.logger.Error(err)
|
||||
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
dbOptions := []channeldb.OptionModifier{
|
||||
channeldb.OptionDryRunMigration(cfg.DryRunMigration),
|
||||
channeldb.OptionKeepFailedPaymentAttempts(
|
||||
@@ -1098,6 +1081,10 @@ func (d *DefaultDatabaseBuilder) BuildDatabase(
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
// The graph store implementation we will use depends on whether
|
||||
// native SQL is enabled or not.
|
||||
var graphStore graphdb.V1Store
|
||||
|
||||
// Instantiate a native SQL store if the flag is set.
|
||||
if d.cfg.DB.UseNativeSQL {
|
||||
migrations := sqldb.GetMigrations()
|
||||
@@ -1156,17 +1143,27 @@ func (d *DefaultDatabaseBuilder) BuildDatabase(
|
||||
// the base DB and transaction executor for the native SQL
|
||||
// invoice store.
|
||||
baseDB := dbs.NativeSQLStore.GetBaseDB()
|
||||
executor := sqldb.NewTransactionExecutor(
|
||||
invoiceExecutor := sqldb.NewTransactionExecutor(
|
||||
baseDB, func(tx *sql.Tx) invoices.SQLInvoiceQueries {
|
||||
return baseDB.WithTx(tx)
|
||||
},
|
||||
)
|
||||
|
||||
sqlInvoiceDB := invoices.NewSQLStore(
|
||||
executor, clock.NewDefaultClock(),
|
||||
invoiceExecutor, clock.NewDefaultClock(),
|
||||
)
|
||||
|
||||
dbs.InvoiceDB = sqlInvoiceDB
|
||||
|
||||
graphStore, err = d.getGraphStore(
|
||||
baseDB, databaseBackends.GraphDB, graphDBOptions...,
|
||||
)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("unable to get graph store: %w", err)
|
||||
d.logger.Error(err)
|
||||
|
||||
return nil, nil, err
|
||||
}
|
||||
} else {
|
||||
// Check if the invoice bucket tombstone is set. If it is, we
|
||||
// need to return and ask the user switch back to using the
|
||||
@@ -1188,6 +1185,23 @@ func (d *DefaultDatabaseBuilder) BuildDatabase(
|
||||
}
|
||||
|
||||
dbs.InvoiceDB = dbs.ChanStateDB
|
||||
|
||||
graphStore, err = graphdb.NewKVStore(
|
||||
databaseBackends.GraphDB, graphDBOptions...,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
}
|
||||
|
||||
dbs.GraphDB, err = graphdb.NewChannelGraph(graphStore, chanGraphOpts...)
|
||||
if err != nil {
|
||||
cleanUp()
|
||||
|
||||
err = fmt.Errorf("unable to open channel graph DB: %w", err)
|
||||
d.logger.Error(err)
|
||||
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
// Wrap the watchtower client DB and make sure we clean up.
|
||||
|
Reference in New Issue
Block a user