Closed dydxwill closed 4 days ago
The recent updates involve refining test cases, database migration scripts, and Pnl ticks handling in various modules of the indexer packages. Tests were adjusted, new migration scripts were added to manage a blockTime
index, and functionalities were updated to optimize querying and data retrieval processes. Additionally, a new conditional check was introduced in the AUXO service to handle specific migration tasks without creating unnecessary ECS Task Definitions.
File Path | Change Summary |
---|---|
indexer/packages/postgres/__tests__/stores/pnl-ticks-table.test.ts |
Updated test case to expect a count value of 1 instead of 2. |
.../src/db/migrations/migration_files/20240628141851_create_pnl_ticks_block_time_index.ts |
Added migration script to create/drop an index on the blockTime column in pnl_ticks table. |
indexer/packages/postgres/src/stores/pnl-ticks-table.ts |
Updated findLatestProcessedBlocktimeAndCount function to use CTE for querying max block time and count. |
indexer/services/roundtable/__tests__/tasks/pnl-instrumentation.test.ts |
Switched to using getMostRecentPnlTicksForEachAccount from helpers and updated related mock implementations. |
indexer/services/roundtable/src/tasks/pnl-instrumentation.ts |
Modified logic to retrieve recent PNL ticks from Redis instead of database, updating handling of PNL tick times. |
indexer/services/auxo/src/index.ts |
Added conditional early return based on event.onlyRunDbMigrationAndCreateKafkaTopics to avoid creating ECS Task Definitions unnecessarily. |
indexer/services/auxo/src/types.ts |
Introduced a new field onlyRunDbMigrationAndCreateKafkaTopics to AuxoEventJson interface. |
sequenceDiagram
participant Client
participant AuxoService
participant Redis
participant PnlTicksTable
Client->>AuxoService: event with onlyRunDbMigrationAndCreateKafkaTopics
AuxoService-->>Client: Return success early
Client->>AuxoService: request PNL ticks for subaccounts
AuxoService->>Redis: getMostRecentPnlTicksForEachAccount
Redis-->>AuxoService: return recent PNL ticks
AuxoService->>PnlTicksTable: findLatestProcessedBlocktimeAndCount
PnlTicksTable-->>AuxoService: return maxBlockTime and count
AuxoService-->>Client: Return PNL ticks and metadata
In databases deep, where timestamps align,
Optimized queries find block times that shine.
With redis and tests, each tick now improved,
Pnl instruments, precision behooved.
New fields emerge, Kubernetes stands tall,
So here’s to the code, the best of them all! 🐇✨
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
@mergifyio backport release/indexer/v5.x
backport release/indexer/v5.x
Changelist
Add auxo option to only run db migration. Plan is to manually deploy roundtable first to make sure it's not the culprit. Add blockTime index to pnl_ticks table. Without index,
EXPLAIN ANALYZE WITH maxBlockTime AS ( SELECT MAX("blockTime") as "maxBlockTime" FROM "pnl_ticks" ) SELECT maxBlockTime."maxBlockTime" as max, COUNT(*) as count FROM "pnl_ticks", maxBlockTime WHERE "pnl_ticks"."blockTime" = maxBlockTime."maxBlockTime" GROUP BY 1;
has Execution Time: 14363.724 ms. With index, Execution Time: 0.119 msIn pnl instrumentation task, query the cache since data exists there. This will help reduce db load. Remove unused helper functions
Test Plan
See internal mainnet dashboards for decrease in pnl instrumentation task latency Unit tested
Author/Reviewer Checklist
state-breaking
label.indexer-postgres-breaking
label.PrepareProposal
orProcessProposal
, manually add the labelproposal-breaking
.feature:[feature-name]
.backport/[branch-name]
.refactor
,chore
,bug
.Summary by CodeRabbit
New Features
blockTime
column in thepnl_ticks
table for improved query performance.Bug Fixes
Improvements
findLatestProcessedBlocktimeAndCount
for more efficient data retrieval.