[SERVER-48475] Secondary reads always calculate all_durable despite only using lastApplied Created: 28/May/20  Updated: 29/Oct/23  Resolved: 05/Jun/20

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 4.5.1, 4.4.0-rc7
Fix Version/s: 4.4.0-rc9, 4.7.0

Type: Improvement Priority: Major - P3
Reporter: Louis Williams Assignee: Louis Williams
Resolution: Fixed Votes: 0
Labels: bkp
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Related
related to SERVER-44529 Re-acquiring locks after a yield and ... Closed
related to SERVER-46721 Step up may cause reads at PIT with h... Closed
Backwards Compatibility: Fully Compatible
Backport Requested:
v4.4
Sprint: Execution Team 2020-06-15
Participants:
Linked BF Score: 0

 Description   

As of SERVER-46721, reads on secondaries used the no-overlap point, which is computed as the minimum of replication's lastApplied and WT's all_durable timestamps.

On secondaries, lastApplied is only updated at replication batch boundaries, and all_durable may advance as we apply oplog entries out of order. Because we take the minimum value, the no-overlap point is always equal to lastApplied.

Reads on secondaries will perform unnecessary queries for all_durable. This value is not cached, and requires taking a read lock in WT to traverse a queue of commit timestamps.

We can regain some performance for reads by only using lastApplied on secondaries.



 Comments   
Comment by Githook User [ 06/Aug/20 ]

Author:

{'name': 'Louis Williams', 'email': 'louis.williams@mongodb.com', 'username': 'louiswilliams'}

Message: SERVER-46721 Secondary readers should read at the no-overlap time instead of lastApplied

The no-overlap time, ReadSource::kNoOverlap, is the minimum of replication's lastApplied timestamp
and WiredTiger's all_durable time. This time is independent of replication state and ensures
queries do not see oplog holes after state transitions from secondary to primary.

(cherry picked from commit 25c694f365db0f07a445bd17b6cd5cbf32f5f2f9)
(cherry picked from commit 5ddf9db5635e4af2d1295bd2f1007e86d517c6c2)

SERVER-44529 Query yield recovery after a stepdown should switch to read at the no-overlap time

After yielding and reacquiring locks in a query, the preconditions that were used to select our
ReadSource initially need to be checked again. Queries hold an AutoGetCollectionForRead RAII
lock for their lifetime, which may select a ReadSource based on state (e.g. replication
state). After a query yields its locks, this state may have changed, invalidating our current
choice of ReadSource.

(cherry picked from commit b3a5b5258a487006f0487b9e7e0a1d0d4f1119ff)
(cherry picked from commit ce57ddce19e642401ec1b56871b3a9402116ccfc)

SERVER-48475 Reimplement lastApplied for secondary reads

This partially reverts work to use the kNoOverlap ReadSource on secondaries since the all_durable
calculation is unnecessary and expensive.

(cherry picked from commit ff92d4435fa75c2b947c49cffaf48805b320a5ae)
(cherry picked from commit 4e3f3b96826772baa777b7563b38574c1e11c2e4)
Branch: v4.2
https://github.com/mongodb/mongo/commit/caef6619556ddeb20adf8e2bad651b96d2b3ea70

Comment by Githook User [ 05/Jun/20 ]

Author:

{'name': 'Louis Williams', 'email': 'louis.williams@mongodb.com', 'username': 'louiswilliams'}

Message: SERVER-48475 Reimplement lastApplied for secondary reads

This partially reverts work to use the kNoOverlap ReadSource on
secondaries since the all_durable calculation is unnecessary and
expensive.

(cherry picked from commit ff92d4435fa75c2b947c49cffaf48805b320a5ae)
Branch: v4.4
https://github.com/mongodb/mongo/commit/4e3f3b96826772baa777b7563b38574c1e11c2e4

Comment by Githook User [ 05/Jun/20 ]

Author:

{'name': 'Louis Williams', 'email': 'louis.williams@mongodb.com', 'username': 'louiswilliams'}

Message: SERVER-48475 Reimplement lastApplied for secondary reads

This partially reverts work to use the kNoOverlap ReadSource on
secondaries since the all_durable calculation is unnecessary and
expensive.
Branch: master
https://github.com/mongodb/mongo/commit/ff92d4435fa75c2b947c49cffaf48805b320a5ae

Generated at Thu Feb 08 05:17:14 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.