HIGH: [Debugability] [$250] Add logs for network queue length
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
- log the length of persistedRequests when requests get added to the SequentialQueue
- log when a read is being blocked by queued writes here
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
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.
Job added to Upwork: https://www.upwork.com/jobs/~013c1fa89f2e72f914
Triggered auto assignment to Contributor-plus team member for initial proposal review - @mananjadhav (External)
Dibs
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
- log the length of persistedRequests when requests get added to the SequentialQueue
- log when a read is being blocked by queued writes here
More details:
- Add a method to get persisted request length to
PersistedRequests.ts, in here
function getLength(): number {
return persistedRequests.length;
}
- 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());
- 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 thePersistedRequestsat 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);
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 Proposal updated to add the details!
@tienifr's proposal looks good to me.
π π π C+ reviewed.
Current assignee @arosiclair is eligible for the choreEngineerContributorManagement assigner, not assigning anyone new.
π£ @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:
- Make sure you've read and understood the contributing guidelines.
- 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.
- 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.
- Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>
β οΈ Invalid email. Please make sure to create an Expensify account with this email first here.
Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~01c904f03c8c8d30d0
β Contributor details stored successfully. Thank you for contributing to Expensify!
@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`);
}
π£ @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 π
@mananjadhav PR https://github.com/Expensify/App/pull/40619 can be reviewed
@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!
@strepanier03 This is ready for payout and did you get a chance to look at the previous comment by @tienifr.
@strepanier03 Friendly bump on this, thanks!
Quick bump @strepanier03
@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 I'll need a payout summary on the issue to raise it on NewDot. Could you add that as well please?
@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 π
Payment Summary
- @mananjadhav - $500 via Manual Requests
- @tienifr - $500 paid via Upwork
@JmillsExpensify - Payment request incoming.
Go ahead @mananjadhav - I'll close this and let you handle the manual request now.
Thanks again everyone π
$500 approved for @mananjadhav