Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
release: 10.2.2 (#1029)
Browse files Browse the repository at this point in the history
* fix: remove poor performing query from AddOrders (#1028)

* remove extremely inefficient query from AddOrders procedure

Move the routine to the order watcher cleanup loop.

* fix typo

* bump version in core.go

* cut release 10.2.2
  • Loading branch information
opaolini authored Feb 18, 2021
1 parent a05f9a2 commit 1fcb8c7
Show file tree
Hide file tree
Showing 20 changed files with 657 additions and 636 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Version](https://img.shields.io/badge/version-10.2.1-orange.svg)](https://github.com/0xProject/0x-mesh/releases)
[![Version](https://img.shields.io/badge/version-10.2.2-orange.svg)](https://github.com/0xProject/0x-mesh/releases)
[![Docs](https://img.shields.io/badge/docs-website-yellow.svg)](https://0x-org.gitbook.io/mesh)
[![Chat with us on Discord](https://img.shields.io/badge/chat-Discord-blueViolet.svg)](https://discord.gg/HF7fHwk)
[![Circle CI](https://img.shields.io/circleci/project/0xProject/0x-mesh/master.svg)](https://circleci.com/gh/0xProject/0x-mesh/tree/master)
Expand Down
2 changes: 1 addition & 1 deletion core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const (
estimatedNonPollingEthereumRPCRequestsPer24Hrs = 50000
// logStatsInterval is how often to log stats for this node.
logStatsInterval = 5 * time.Minute
version = "10.2.1"
version = "10.2.2"
// ordersyncMinPeers is the minimum amount of peers to receive orders from
// before considering the ordersync process finished.
ordersyncMinPeers = 5
Expand Down
58 changes: 30 additions & 28 deletions db/sql_implementation.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,34 +386,6 @@ func (db *DB) AddOrders(orders []*types.OrderWithMetadata) (alreadyStored []comm
}
}

// Remove orders with an expiration time too far in the future.
// HACK(albrow): sqlz doesn't support ORDER BY, LIMIT, and OFFSET
// for DELETE statements. It also doesn't support RETURNING. As a
// workaround, we do a SELECT and DELETE inside a transaction.
// HACK(albrow): SQL doesn't support limit without offset. As a
// workaround, we set the limit to an extremely large number.
removeQuery := txn.Select("*").From("orders").
OrderBy(sqlz.Desc(string(OFIsPinned)), sqlz.Asc(string(OFExpirationTimeSeconds))).
Limit(largeLimit).
Offset(int64(db.opts.MaxOrders))
var ordersToRemove []*sqltypes.Order
err = removeQuery.GetAllContext(db.ctx, &ordersToRemove)
if err != nil {
return err
}
for _, order := range ordersToRemove {
_, err := txn.DeleteFrom("orders").Where(sqlz.Eq(string(OFHash), order.Hash)).ExecContext(db.ctx)
if err != nil {
return err
}
if _, found := addedMap[order.Hash]; found {
// If the order was previously added, remove it from
// the added set and don't add it to the removed set.
delete(addedMap, order.Hash)
} else {
sqlRemoved = append(sqlRemoved, order)
}
}
return nil
})
if err != nil {
Expand Down Expand Up @@ -498,6 +470,36 @@ func (db *DB) FindOrders(query *OrderQuery) (orders []*types.OrderWithMetadata,
return sqltypes.OrdersToCommonType(foundOrders), nil
}

// Remove orders with an expiration time too far in the future.
func (db *DB) RemoveOrdersWithLongExpiration() ([]*sqltypes.Order, error) {
sqlRemoved := []*sqltypes.Order{}
return sqlRemoved, db.ReadWriteTransactionalContext(db.ctx, nil, func(txn *sqlz.Tx) error {
// HACK(albrow): sqlz doesn't support ORDER BY, LIMIT, and OFFSET
// for DELETE statements. It also doesn't support RETURNING. As a
// workaround, we do a SELECT and DELETE inside a transaction.
// HACK(albrow): SQL doesn't support limit without offset. As a
// workaround, we set the limit to an extremely large number.
removeQuery := txn.Select("*").From("orders").
OrderBy(sqlz.Desc(string(OFIsPinned)), sqlz.Asc(string(OFExpirationTimeSeconds))).
Limit(largeLimit).
Offset(int64(db.opts.MaxOrders))
var ordersToRemove []*sqltypes.Order
err := removeQuery.GetAllContext(db.ctx, &sqlRemoved)
if err != nil {
return err
}
for _, order := range ordersToRemove {
_, err := txn.DeleteFrom("orders").Where(sqlz.Eq(string(OFHash), order.Hash)).ExecContext(db.ctx)
if err != nil {
return err
}
sqlRemoved = append(sqlRemoved, order)
}

return nil
})
}

func (db *DB) CountOrders(query *OrderQuery) (count int, err error) {
defer func() {
err = convertErr(err)
Expand Down
2 changes: 1 addition & 1 deletion docs/browser-bindings/browser-lite/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# @0x/mesh-browser-lite - v10.2.1
# @0x/mesh-browser-lite - v10.2.2

## @0x/mesh-browser-lite

Expand Down
Loading

0 comments on commit 1fcb8c7

Please sign in to comment.