mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-10-11 12:23:00 +02:00
graph/db+sqldb: make channel SQL mig retry-safe
In this commit, we make the channel part of the graph SQL migration idempotent (retry-safe!). We do this by adding a migration-only channel insert query that will not error out if a the query is called and a chanenl with the given scid&version already exists. We also ensure that errors are not thrown if existing channel features & extra types are re-added.
This commit is contained in:
@@ -16,7 +16,6 @@ type Querier interface {
|
||||
ClearKVInvoiceHashIndex(ctx context.Context) error
|
||||
CountZombieChannels(ctx context.Context, version int16) (int64, error)
|
||||
CreateChannel(ctx context.Context, arg CreateChannelParams) (int64, error)
|
||||
CreateChannelExtraType(ctx context.Context, arg CreateChannelExtraTypeParams) error
|
||||
DeleteCanceledInvoices(ctx context.Context) (sql.Result, error)
|
||||
DeleteChannelPolicyExtraTypes(ctx context.Context, channelPolicyID int64) error
|
||||
DeleteChannels(ctx context.Context, ids []int64) error
|
||||
@@ -90,6 +89,12 @@ type Querier interface {
|
||||
InsertAMPSubInvoiceHTLC(ctx context.Context, arg InsertAMPSubInvoiceHTLCParams) error
|
||||
InsertChanPolicyExtraType(ctx context.Context, arg InsertChanPolicyExtraTypeParams) error
|
||||
InsertChannelFeature(ctx context.Context, arg InsertChannelFeatureParams) error
|
||||
// NOTE: This query is only meant to be used by the graph SQL migration since
|
||||
// for that migration, in order to be retry-safe, we don't want to error out if
|
||||
// we re-insert the same channel again (which would error if the normal
|
||||
// CreateChannel query is used because of the uniqueness constraint on the scid
|
||||
// and version columns).
|
||||
InsertChannelMig(ctx context.Context, arg InsertChannelMigParams) (int64, error)
|
||||
InsertClosedChannel(ctx context.Context, scid []byte) error
|
||||
InsertInvoice(ctx context.Context, arg InsertInvoiceParams) (int64, error)
|
||||
InsertInvoiceFeature(ctx context.Context, arg InsertInvoiceFeatureParams) error
|
||||
@@ -130,6 +135,7 @@ type Querier interface {
|
||||
UpdateInvoiceHTLCs(ctx context.Context, arg UpdateInvoiceHTLCsParams) error
|
||||
UpdateInvoiceState(ctx context.Context, arg UpdateInvoiceStateParams) (sql.Result, error)
|
||||
UpsertAMPSubInvoice(ctx context.Context, arg UpsertAMPSubInvoiceParams) (sql.Result, error)
|
||||
UpsertChannelExtraType(ctx context.Context, arg UpsertChannelExtraTypeParams) error
|
||||
UpsertEdgePolicy(ctx context.Context, arg UpsertEdgePolicyParams) (int64, error)
|
||||
UpsertNode(ctx context.Context, arg UpsertNodeParams) (int64, error)
|
||||
UpsertNodeAddress(ctx context.Context, arg UpsertNodeAddressParams) error
|
||||
|
Reference in New Issue
Block a user