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

add cancel-stuck-transactions #363

Merged
merged 10 commits into from
Sep 24, 2024

Conversation

juliangruber
Copy link
Member

No description provided.

Copy link
Member

@bajtos bajtos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am concerned about coupling the database schema with the data structure used by the cancellation library. But I guess that's easy to change later.

The rest of the changes LGTM.

Remember to fix the failing tests.

bin/spark-evaluate.js Outdated Show resolved Hide resolved
bin/spark-evaluate.js Outdated Show resolved Hide resolved
bin/spark-evaluate.js Outdated Show resolved Hide resolved
lib/evaluate.js Outdated Show resolved Hide resolved
@juliangruber juliangruber marked this pull request as draft September 24, 2024 09:58
@juliangruber

This comment was marked as outdated.

@juliangruber juliangruber marked this pull request as ready for review September 24, 2024 10:34
lib/cancel-stuck-transactions.js Outdated Show resolved Hide resolved
lib/evaluate.js Outdated
@@ -147,9 +149,10 @@ export const evaluate = async ({

const start = Date.now()
const buckets = createSetScoresBuckets(participants)
let tx
for (const [bucketIndex, bucket] of Object.entries(buckets)) {
try {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is how I understand your new version at the high level:

  let tx
  for (const [bucketIndex, bucket] of Object.entries(buckets)) {
    tx = await ieContractWithSigner.setScores // etc.
  }
  tx.wait()

This code will wait only for the last transaction created.

If that's intentional, then let's make it more obvious to the reader, please.

For example:

  let lastTx
  for (const [bucketIndex, bucket] of Object.entries(buckets)) {
    const tx = await ieContractWithSigner.setScores // etc.
    lastTx = tx
  }
  // add a comment explaining why we wait for the last transaction only
  // and don't need to wait for other transactions
  lastTx.wait()

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was even more broken. Each tx should be awaited and then marked as confirmed. Fixed 👍

Copy link
Member

@bajtos bajtos Sep 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be worth creating a test to verify this works as intended. However, mocking all the dependencies to simulate two TXs running concurrently will require quite a bit of code, so it may not be the best use of our time right now.

lib/evaluate.js Outdated Show resolved Hide resolved
migrations/017.do.cancel-stuck-transactions.sql Outdated Show resolved Hide resolved
Copy link
Member

@bajtos bajtos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌🏻

@juliangruber juliangruber merged commit cce5c11 into main Sep 24, 2024
6 checks passed
@juliangruber juliangruber deleted the add/integrate-cancel-stuck-transactions branch September 24, 2024 12:52
@juliangruber
Copy link
Member Author

Will now mirror this to spark-publish

Copy link

sentry-io bot commented Sep 25, 2024

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ TypeError: fetch failed startCancelStuckTransactions(cancel-stuck-trans... View Issue
  • ‼️ Error: Filfox request failed with 502: startCancelStuckTransactions(cancel-stuck-trans... View Issue

Did you find this useful? React with a 👍 or 👎

@juliangruber
Copy link
Member Author

juliangruber commented Sep 25, 2024

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ TypeError: Cannot mix BigInt and other types, use explicit conversions startCancelStuckTransactions(cancel-stuck-trans... View Issue

Strange! In the example script of cancel-stuck-transaction, it works, with the same version of ethers. I'm taking a closer look.

  • ‼️ Error: Filfox request failed with 500: {"statusCode":500,"message":"Internal server error"} startCancelStuckTransactions(cancel-stuck-trans... View Issue

I'll either add retry logic or let it fail more silently (the whole op will be retried anyway)

@juliangruber
Copy link
Member Author

juliangruber commented Sep 25, 2024

Strange! In the example script of cancel-stuck-transaction, it works, with the same version of ethers. I'm taking a closer look.

I think I know what happens: When reading from postgres, it doesn't return a BigInt

@juliangruber
Copy link
Member Author

brianc/node-pg-types#78

@juliangruber
Copy link
Member Author

juliangruber commented Sep 25, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ done
Development

Successfully merging this pull request may close these issues.

2 participants