Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

integrating new loaders and builders into processors #5083

Merged
merged 14 commits into from
Oct 26, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
#4909: fixed bulk asset insertion order id's after sorting by asset t…
…exts, trade processor depends on ordered id's for buyer/seller delineation
sreuland committed Oct 24, 2023
commit 80cfc01e752bb06d8a2990248d490737811028c4
23 changes: 9 additions & 14 deletions services/horizon/internal/db2/history/asset_loader.go
Original file line number Diff line number Diff line change
@@ -22,6 +22,10 @@ type AssetKey struct {
Issuer string
}

func (key AssetKey) String() string {
return key.Type + "/" + key.Code + "/" + key.Issuer
sreuland marked this conversation as resolved.
Show resolved Hide resolved
}

// AssetKeyFromXDR constructs an AssetKey from an xdr asset
func AssetKeyFromXDR(asset xdr.Asset) AssetKey {
return AssetKey{
@@ -142,6 +146,11 @@ func (a *AssetLoader) Exec(ctx context.Context, session db.SessionInterface) err
assetTypes := make([]string, 0, len(a.set)-len(a.ids))
assetCodes := make([]string, 0, len(a.set)-len(a.ids))
assetIssuers := make([]string, 0, len(a.set)-len(a.ids))
// sort entries before inserting rows to prevent deadlocks on acquiring a ShareLock
// https://github.com/stellar/go/issues/2370
sort.Slice(keys, func(i, j int) bool {
return keys[i].String() < keys[j].String()
})
insert := 0
for _, key := range keys {
if _, ok := a.ids[key]; ok {
@@ -157,20 +166,6 @@ func (a *AssetLoader) Exec(ctx context.Context, session db.SessionInterface) err
return nil
}
keys = keys[:insert]
// sort entries before inserting rows to prevent deadlocks on acquiring a ShareLock
// https://github.com/stellar/go/issues/2370
sort.Slice(keys, func(i, j int) bool {
if keys[i].Type < keys[j].Type {
return true
}
if keys[i].Code < keys[j].Code {
return true
}
if keys[i].Issuer < keys[j].Issuer {
return true
}
return false
})

err := bulkInsert(
ctx,
Loading