App icon indicating copy to clipboard operation
App copied to clipboard

HIGH: [Debugability] [$250] Add logs for network queue length

Open arosiclair opened this issue 2 years ago β€’ 17 comments

Problem

It's difficult to recognize when there is an issue with the App's network queue especially in production. If the queue gets stuck and fails to process any new requests, it's difficult to recognize when this is happening without logging. This is a critical problem because all reads are blocked on the write queue.

Solution

Add the current length of the network queue to the log whenever another API command is queued. This should make it easy to recognize when the app is failing to clear the queue just by viewing logs.

Specifically, we should

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~013c1fa89f2e72f914
  • Upwork Job ID: 1780254517492736000
  • Last Price Increase: 2024-04-16
  • Automatic offers:
    • tienifr | Contributor | 0

arosiclair avatar Apr 16 '24 15:04 arosiclair

Triggered auto assignment to @strepanier03 (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

melvin-bot[bot] avatar Apr 16 '24 15:04 melvin-bot[bot]

Job added to Upwork: https://www.upwork.com/jobs/~013c1fa89f2e72f914

melvin-bot[bot] avatar Apr 16 '24 15:04 melvin-bot[bot]

Triggered auto assignment to Contributor-plus team member for initial proposal review - @mananjadhav (External)

melvin-bot[bot] avatar Apr 16 '24 15:04 melvin-bot[bot]

Dibs

gijoe0295 avatar Apr 16 '24 15:04 gijoe0295

Proposal

Please re-state the problem that we are trying to solve in this issue.

We want to add logs for network queue length

What is the root cause of that problem?

This is new feature.

What changes do you think we should make in order to solve the problem?

We should

More details:

  1. Add a method to get persisted request length to PersistedRequests.ts, in here
function getLength(): number {
    return persistedRequests.length;
}
  1. In here, log the length of persistedRequests when requests get added to the SequentialQueue
Log.info('[RequestQueue] New request saved to PersistedRequests, the length of queue is currently ' + PersistedRequests.getLength());
  1. Log when a read is being blocked by queued writes here, using similar log as 2. We can check if the read is blocked by checking if there's any write request in the PersistedRequests at the time the read is being done:
if (PersistedRequests.getLength() > 0) {
    Log.info('[RequestQueue] The read command ' + command + ' is being blocked by ' + PersistedRequests.getLength() + ' write requests');
}

The message format can be adjusted according to the requirements.

What alternative solutions did you explore? (Optional)

Instead of defining the new method to get length, can just use getAll().length.

As far as I can see, only write requests will end up in the persistedRequests queue. If somehow I'm wrong, then in step 3 we might have to filter out the write requests to get its length

const writeRequests = PersistedRequests.getAll().filter(request => request?.data?.apiRequestType === CONST.API_REQUEST_TYPE.WRITE);

tienifr avatar Apr 16 '24 15:04 tienifr

While I understand the job is straight forward, @gijoe0295 @tienifr let's have a basic content on the proposal. Let's not copy-paste GH issue description.

mananjadhav avatar Apr 16 '24 15:04 mananjadhav

@mananjadhav Proposal updated to add the details!

tienifr avatar Apr 16 '24 15:04 tienifr

@tienifr's proposal looks good to me.

πŸŽ€ πŸ‘€ πŸŽ€ C+ reviewed.

mananjadhav avatar Apr 16 '24 16:04 mananjadhav

Current assignee @arosiclair is eligible for the choreEngineerContributorManagement assigner, not assigning anyone new.

melvin-bot[bot] avatar Apr 16 '24 16:04 melvin-bot[bot]

πŸ“£ @dharmeshsavaliya! πŸ“£ Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork. Please follow these steps:

  1. Make sure you've read and understood the contributing guidelines.
  2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details. Screen Shot 2022-11-16 at 4 42 54 PM Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>

melvin-bot[bot] avatar Apr 16 '24 18:04 melvin-bot[bot]

⚠️ Invalid email. Please make sure to create an Expensify account with this email first here.

melvin-bot[bot] avatar Apr 16 '24 18:04 melvin-bot[bot]

Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~01c904f03c8c8d30d0

dharmeshsavaliya avatar Apr 16 '24 18:04 dharmeshsavaliya

βœ… Contributor details stored successfully. Thank you for contributing to Expensify!

melvin-bot[bot] avatar Apr 16 '24 18:04 melvin-bot[bot]

@tienifr's proposal looks good let's just modify the logs slightly:

Log.info(`[SequentialQueue] '${commandName}' command queued. Queue length is ${PersistedRequests.getLength()}`);
if (PersistedRequests.getLength() > 0) {
    Log.info(`[API] '${commandName}' is waiting on ${PersistedRequests.getLength()} write commands`);
}

arosiclair avatar Apr 17 '24 15:04 arosiclair

πŸ“£ @tienifr πŸŽ‰ An offer has been automatically sent to your Upwork account for the Contributor role πŸŽ‰ Thanks for contributing to the Expensify app!

Offer link Upwork job Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review πŸ§‘β€πŸ’» Keep in mind: Code of Conduct | Contributing πŸ“–

melvin-bot[bot] avatar Apr 17 '24 15:04 melvin-bot[bot]

@mananjadhav PR https://github.com/Expensify/App/pull/40619 can be reviewed

tienifr avatar Apr 20 '24 04:04 tienifr

@strepanier03 This issue is HIGH priority, thus I believe the price should be $500 according to the announcement

While bugs/feature requests will now start at $250, any that are deemed Critical or High to our roadmap (noted via the label High Priority) will automatically be updated to $500. This is to ensure we get the necessary attention and urgency applied to these issues.

Could you help to update the issue if all good? Thanks!

tienifr avatar Apr 24 '24 09:04 tienifr

@strepanier03 This is ready for payout and did you get a chance to look at the previous comment by @tienifr.

mananjadhav avatar May 01 '24 19:05 mananjadhav

@strepanier03 Friendly bump on this, thanks!

tienifr avatar May 07 '24 12:05 tienifr

Quick bump @strepanier03

mananjadhav avatar May 07 '24 19:05 mananjadhav

@tienifr - Can you accept the offer so I can pay it at $500? Or I can cancel the offer entirely and make a new one, your choice.

strepanier03 avatar May 07 '24 20:05 strepanier03

@strepanier03 I'll need a payout summary on the issue to raise it on NewDot. Could you add that as well please?

mananjadhav avatar May 07 '24 20:05 mananjadhav

@tienifr - Can you accept the offer so I can pay it at $500? Or I can cancel the offer entirely and make a new one, your choice.

@strepanier03 Let's use the same offer, I accepted it, thanks πŸ™

tienifr avatar May 08 '24 02:05 tienifr

Payment Summary

  • @mananjadhav - $500 via Manual Requests
  • @tienifr - $500 paid via Upwork

@JmillsExpensify - Payment request incoming.

strepanier03 avatar May 08 '24 23:05 strepanier03

Go ahead @mananjadhav - I'll close this and let you handle the manual request now.

Thanks again everyone πŸ™Œ

strepanier03 avatar May 08 '24 23:05 strepanier03

$500 approved for @mananjadhav

JmillsExpensify avatar May 12 '24 13:05 JmillsExpensify