[SERVER-74116] Use batched writes when inserting and updating logical sessions Created: 16/Feb/23  Updated: 13/Apr/23  Resolved: 13/Apr/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: Shin Yee Tan Assignee: Shin Yee Tan
Resolution: Won't Do Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Sprint: Execution Team 2023-04-03, Execution Team 2023-04-17
Participants:

 Description   

Currently when we refresh sessions, there are inserts and updates to the sessions collection that we write to the oplog. We can use batched writes to batch these upserts into an applyOps.

Things to consider:

  • single inserts/updates should not be in an applyOps
  • whether inserts and updates are batched together or separately


 Comments   
Comment by Shin Yee Tan [ 13/Apr/23 ]

To answer the previous question, we are able to batch inserts that call the write unit of work more directly and are not going through the regular query path.

Trying to refactor how sessions refresh may introduce more tech debt and the more ideal and generalized approach would be to introduce batching logic at the query level. A BatchedUpdateStage/BatchedUpsertStage would enable fully utilizing the batching functionality we have. Thus, I am closing this ticket in favor of SERVER-76055.

Comment by Shin Yee Tan [ 30/Mar/23 ]

After poking around the codebase, some things I want to note down are:

  • Updates when upserts is true will write an insert instead of update when object doesn't exist yet
  • Logical sessions writes its updates with the regular update path because we use dbclient
    • I wonder if this may be a place for refactoring such that we try to call performUpdates() in write_exec_ops.cpp more directly
  • I wonder if we need BatchedUpdateStage similar to BatchedDeleteStage to have a more generic solution to batch updates when we see multiple at once
  • Questions: We know that batched inserts work but we don't have a BatchedInsertStage. How are we batching inserts without it and do we need a BatchedInsertStage?
Generated at Thu Feb 08 06:26:33 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.