Skip to content

osd/scrub: reserve replicas in OSD order, one by one - #53843

Merged
ronen-fr merged 10 commits into
ceph:mainfrom
ronen-fr:wip-rf-1b1
Nov 2, 2023
Merged

ronen-fr merged 10 commits into
ceph:mainfrom
ronen-fr:wip-rf-1b1

Conversation

@ronen-fr

@ronen-fr ronen-fr commented Oct 5, 2023 •

Copy link
Copy Markdown
Contributor

The handling of replicas reservation in the beginning of each scrub session is modified:

Now - issuing the reservation requests one by one - waiting for
approval from the secondary before the next request is sent.

The requests are sent in ascending pg_shard_t order, reducing the chance
of having two PGs repeatedly competing for the same set of
OSDs - and doing so in an interleaved sequence.

Based on an observation made by Sam Just.

Comment thread src/osd/scrubber/pg_scrubber.cc Resolved
Comment thread src/osd/scrubber/pg_scrubber.cc Resolved
Comment thread src/osd/scrubber/pg_scrubber.cc Resolved
Comment thread src/osd/scrubber/pg_scrubber.cc Resolved
Comment thread src/osd/scrubber/pg_scrubber.cc Resolved

@athanatos athanatos left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Seems mostly correct but we can make it a lot simpler.

Comment thread src/osd/scrubber/pg_scrubber.cc Resolved
Comment thread src/osd/scrubber/pg_scrubber.cc Resolved
Comment thread src/osd/scrubber/scrub_reservations.h Resolved
Comment thread src/osd/scrubber/scrub_reservations.h Resolved
Comment thread src/osd/scrubber/scrub_reservations.h Resolved
Comment thread src/osd/scrubber/scrub_reservations.h Resolved
Comment thread src/osd/scrubber/scrub_machine.cc Resolved
Comment thread src/osd/scrubber/scrub_machine.h Outdated

/// a new interval has dawned.
/// For a Primary: Discards replica reservations, so that the FullReset that would
/// follow it would not attempt to release them.

@athanatos athanatos Oct 6, 2023 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's be a bit more explanatory here:

/**
 * IntervalChanged
 *
 * This event notifies the ScrubMachine that it is no longer responsible for
 * releasing replica state.  It will generally be submitted upon a PG interval
 * change and followed immediately by a FullReset.
 * 
 * This event is distinct from FullReset because replicas are always responsible
 * for releasing any interval specific state (including but certainly not limited to
 * scrub reservations) upon interval change without coordination from the
 * Primary.  This event notifies the ScrubMachine that it can forget about
 * such remote state.
 */

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Lost this change in the process. Will fix in the next round of changes.

Comment thread src/osd/scrubber/scrub_reservations.h Resolved

/// managing the scrub session's reservations (optiona, as
/// it's an RAII wrapper around the state of 'holding reservations')
std::optional<ReplicaReservations> m_reservations{std::nullopt};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

First, an initially constructed ReplicaReservations should be represent "no replicas reserved thus far", which I think is what std::nullopt should represent as well. No need for this to be an optional.

More significantly, I don't see any purpose for the ReplicaReservations class. It requires a bunch of boilerplate code for capturing interfaces already held by the scrubber. With the comments I made above, it should have only three real members:

  • m_sorted_secondaries (rename to replicas_to_reserve)
  • m_next_to_request (rename to next_replica_to_reserve)
  • m_request_sent_at (rename to last_reservation_request_sent_at or something)

I think if you simply move the members and methods directly to Session, the code will be vastly easier to scan and no more complex as Session really doesn't do much else.

Only the PG that had set the 'I am in the process of
reserving my replicas' is allowed to clear that status.

That will simplify the follow-up commit, setting this flag from
a specific scrub-FSM state.

Signed-off-by: Ronen Friedman <[email protected]>
The Session state now includes the ReservingReplicas & Active
sub-states.

This new state will hold (in future commits) most of the scrub
state information that relates to a specific scrub session (and
should be cleaned up when that session terminates).

Signed-off-by: Ronen Friedman <[email protected]>
Issuing the reservation requests one by one - waiting for
approval from the secondary before the next request is sent.

The requests are sent in ascending target pg-shard-id order, reducing the
chance of having two PGs repeatedly competing for the same set of
OSDs - and doing so in an interleaved sequence.

Modifying the Session state in the scrubber FSM to react to interval
changes by discarding replica reservations.

Signed-off-by: Ronen Friedman <[email protected]>
The scrubber FSM will now be responsible for handling the grant/deny
ops received from the replica OSDs.
For this temporary step - the scrubber FSM will simply forward a
call to the ReplicaReservations object in the Scrubber.

Signed-off-by: Ronen Friedman <[email protected]>
As a preliminary step before ReplicaReservations ownership
is moved to the scrubber's FSM.

No code changes in this commit (apart from required 'include's).

Signed-off-by: Ronen Friedman <[email protected]>
Handle grant/deny messages within the FSM.
One exception at this point: the handling of "granted by everyone"
(due to the technical inconvenience of having to handle the
"0 replicas" case in the FSM state constructor).

Note: after this commit, ScrubMachineListener - an API which is
a subset of the Scrubber API to be used by the Scrubber FSM - does
no longer make sense. The FSM should now have full access to the
scrubber, and that interface will be removed in a subsequent PR.

Signed-off-by: Ronen Friedman <[email protected]>
with special handling for the 0-replica case.

Signed-off-by: Ronen Friedman <[email protected]>
Merging the 'do once' functionality into the timeout duration.

Signed-off-by: Ronen Friedman <[email protected]>
@ronen-fr
ronen-fr marked this pull request as ready for review October 14, 2023 19:01
@ronen-fr
ronen-fr requested a review from a team as a code owner October 14, 2023 19:01

@athanatos athanatos left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Minor naming nit aside, seems reasonable.

I'm still somewhat skeptical about the strategy. This implementation fails the entire reservation process as soon as one fails, right? I'm not sure that's actually any better than the behavior as it exists now. It might actually be worse since the reservation process could take longer before failing increasing the amount of time we unproductively (if it ultimately fails) hold reservations.

If the goal is to move forward with subsequent PRs retrying the single failure and then with modifying the replica side to an AsyncReserver to queue reservation requests as with Backfill, I think this is a reasonable stepping stone.

scrbr->clear_pgscrub_state();
// manipulate the 'next to reserve' iterator to exclude
// the rejecting replica from the set of replicas requiring release
context<Session>().m_reservations->verify_rejections_source(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Seems like a very misleading name. How about notify_reservation_rejected()?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The name matches the functionality as after the rest of the commits (where the notification part was
moved to the FSM). But I will remove the extra 's' there.

As replicas are now reserved sequentially, the scrub reservation
timeout should be extended.

Taking into account the low priority of scrub-related messages,
modify both 'osd_scrub_reservation_timeout' and
'osd_scrub_slow_reservation_response'.

Signed-off-by: Ronen Friedman <[email protected]>
@ljflores

Copy link
Copy Markdown
Member

jenkins test make check

@ljflores

ljflores commented Oct 27, 2023 •

Copy link
Copy Markdown
Member

@ronen-fr I see a possible related failure. Can you take a look?

/a/yuriw-2023-10-24_00:11:54-rados-wip-yuri4-testing-2023-10-23-0903-distro-default-smithi/7435623

2023-10-25T05:03:50.408 INFO:tasks.workunit.client.0.smithi083.stderr:/home/ubuntu/cephtest/clone.client.0/qa/standalone/scrub/osd-scrub-repair.sh:525: TEST_auto_repair_bluestore_scrub:  rados --pool testpool get SOMETHING td/osd-scrub-repair/COPY
2023-10-25T05:03:50.434 INFO:tasks.workunit.client.0.smithi083.stderr:/home/ubuntu/cephtest/clone.client.0/qa/standalone/scrub/osd-scrub-repair.sh:526: TEST_auto_repair_bluestore_scrub:  diff td/osd-scrub-repair/ORIGINAL td/osd-scrub-repair/COPY
2023-10-25T05:03:50.435 INFO:tasks.workunit.client.0.smithi083.stderr:/home/ubuntu/cephtest/clone.client.0/qa/standalone/scrub/osd-scrub-repair.sh:527: TEST_auto_repair_bluestore_scrub:  grep scrub_finish td/osd-scrub-repair/osd.1.log
2023-10-25T05:03:50.437 INFO:tasks.workunit.client.0.smithi083.stdout:2023-10-25T05:03:28.526+0000 7f6cc3438640 10 osd.1 pg_epoch: 26 pg[1.0( v 21'1 (0'0,21'1] local-lis/les=25/26 n=1 ec=16/16 lis/c=25/25 les/c/f=26/26/0 sis=25) [1,0] r=0 lpr=25 crt=21'1 lcod 0'0 mlcod 0'0 active+clean+scrubbing [ 1.0:  DEEP_SCRUB_ON_ERROR ]  planned DEEP_SCRUB_ON_ERROR] scrubber<Session/Act/WaitDigestUpdate>: scrub_finish before flags:  DEEP_SCRUB_ON_ERROR. repair state: no-repair. deep_scrub_on_error: 1
2023-10-25T05:03:50.437 INFO:tasks.workunit.client.0.smithi083.stdout:2023-10-25T05:03:28.526+0000 7f6cc3438640 15 osd.1 pg_epoch: 26 pg[1.0( v 21'1 (0'0,21'1] local-lis/les=25/26 n=1 ec=16/16 lis/c=25/25 les/c/f=26/26/0 sis=25) [1,0] r=0 lpr=25 crt=21'1 lcod 0'0 mlcod 0'0 active+clean+scrubbing [ 1.0:  DEEP_SCRUB_ON_ERROR ] ] scrubber<Session/Act/WaitDigestUpdate>: scrub_finish Try to auto repair after scrub errors
2023-10-25T05:03:50.437 INFO:tasks.workunit.client.0.smithi083.stdout:2023-10-25T05:03:28.526+0000 7f6cc3438640 10 osd.1 pg_epoch: 26 pg[1.0( v 21'1 (0'0,21'1] local-lis/les=25/26 n=1 ec=16/16 lis/c=25/25 les/c/f=26/26/0 sis=25) [1,0] r=0 lpr=25 crt=21'1 lcod 0'0 mlcod 0'0 active+clean+scrubbing [ 1.0:  ] ] scrubber<Session/Act/WaitDigestUpdate>: _scrub_finish info stats: valid m_is_repair: 0
2023-10-25T05:03:50.438 INFO:tasks.workunit.client.0.smithi083.stdout:2023-10-25T05:03:29.535+0000 7f6cc3438640 10 osd.1 pg_epoch: 26 pg[1.0( v 21'1 (0'0,21'1] local-lis/les=25/26 n=1 ec=16/16 lis/c=25/25 les/c/f=26/26/0 sis=25) [1,0] r=0 lpr=25 crt=21'1 lcod 0'0 mlcod 0'0 active+clean+scrubbing+deep+inconsistent [ 1.0:  AUTO_REPAIR ]  planned AUTO_REPAIR TIME_FOR_DEEP] scrubber<Session/Act/WaitDigestUpdate>: scrub_finish before flags:  AUTO_REPAIR. repair state: no-repair. deep_scrub_on_error: 0
2023-10-25T05:03:50.438 INFO:tasks.workunit.client.0.smithi083.stdout:2023-10-25T05:03:29.535+0000 7f6cc3438640 10 osd.1 pg_epoch: 26 pg[1.0( v 21'1 (0'0,21'1] local-lis/les=25/26 n=1 ec=16/16 lis/c=25/25 les/c/f=26/26/0 sis=25) [1,0] r=0 lpr=25 crt=21'1 lcod 0'0 mlcod 0'0 active+clean+scrubbing+deep+inconsistent [ 1.0:  AUTO_REPAIR ] ] scrubber<Session/Act/WaitDigestUpdate>: _scrub_finish info stats: valid m_is_repair: 1
2023-10-25T05:03:50.438 INFO:tasks.workunit.client.0.smithi083.stdout:2023-10-25T05:03:29.535+0000 7f6cc3438640 15 osd.1 pg_epoch: 26 pg[1.0( v 21'1 (0'0,21'1] local-lis/les=25/26 n=1 ec=16/16 lis/c=25/25 les/c/f=26/26/0 sis=25) [1,0] r=0 lpr=25 crt=21'1 lcod 0'0 mlcod 0'0 active+scrubbing+deep+inconsistent+repair [ 1.0:  AUTO_REPAIR ]  mbc={255={(1+0)=1}}] scrubber<Session/Act/WaitDigestUpdate>: scrub_finish: 1 errors. 1 errors fixed
2023-10-25T05:03:50.438 INFO:tasks.workunit.client.0.smithi083.stdout:2023-10-25T05:03:29.535+0000 7f6cc3438640 20 osd.1 pg_epoch: 26 pg[1.0( v 21'1 (0'0,21'1] local-lis/les=25/26 n=1 ec=16/16 lis/c=25/25 les/c/f=26/26/0 sis=25) [1,0] r=0 lpr=25 crt=21'1 lcod 0'0 mlcod 0'0 active+scrubbing+deep+inconsistent+repair [ 1.0:  AUTO_REPAIR ]  mbc={255={(1+0)=1}}] scrubber<Session/Act/WaitDigestUpdate>: scrub_finish All may be fixed
2023-10-25T05:03:50.439 INFO:tasks.workunit.client.0.smithi083.stdout:2023-10-25T05:03:29.535+0000 7f6cc3438640 19 osd.1 pg_epoch: 26 pg[1.0( v 21'1 (0'0,21'1] local-lis/les=25/26 n=1 ec=16/16 lis/c=25/25 les/c/f=26/26/0 sis=25) [1,0] r=0 lpr=25 crt=21'1 lcod 0'0 mlcod 0'0 active+scrubbing+deep+inconsistent+repair [ 1.0:  AUTO_REPAIR ]  mbc={255={(1+0)=1}}] scrubber<Session/Act/WaitDigestUpdate>: scrub_finish shard 1 num_omap_bytes = 0 num_omap_keys = 0
2023-10-25T05:03:50.439 INFO:tasks.workunit.client.0.smithi083.stderr://home/ubuntu/cephtest/clone.client.0/qa/standalone/scrub/osd-scrub-repair.sh:530: TEST_auto_repair_bluestore_scrub:  ceph pg 1.0 query
2023-10-25T05:03:50.439 INFO:tasks.workunit.client.0.smithi083.stderr://home/ubuntu/cephtest/clone.client.0/qa/standalone/scrub/osd-scrub-repair.sh:530: TEST_auto_repair_bluestore_scrub:  jq .info.stats.stat_sum.num_objects_repaired
2023-10-25T05:03:50.568 INFO:tasks.workunit.client.0.smithi083.stderr:/home/ubuntu/cephtest/clone.client.0/qa/standalone/scrub/osd-scrub-repair.sh:530: TEST_auto_repair_bluestore_scrub:  COUNT=0
2023-10-25T05:03:50.568 INFO:tasks.workunit.client.0.smithi083.stderr:/home/ubuntu/cephtest/clone.client.0/qa/standalone/scrub/osd-scrub-repair.sh:531: TEST_auto_repair_bluestore_scrub:  test 0 = 1
2023-10-25T05:03:50.568 INFO:tasks.workunit.client.0.smithi083.stderr:/home/ubuntu/cephtest/clone.client.0/qa/standalone/scrub/osd-scrub-repair.sh:531: TEST_auto_repair_bluestore_scrub:  return 1

I reran the job 10x too, in case it helps:
http://pulpito.front.sepia.ceph.com/lflores-2023-10-27_18:49:41-rados-wip-yuri4-testing-2023-10-23-0903-distro-default-smithi/

@ljflores

Copy link
Copy Markdown
Member

Removing from the test batch till we figure out whether this failure is related.

As we now call clear_pgscrub_state() at the end of each
'Session' state, we must not clear PG_STATE_REPAIR
unconditionally.

Previously - scrubs that reached normal completion, i.e.
reached PgScrubber::scrub_finish(), would have only cleared
that PG flag under specific conditions. That was changed in
previous commits of this PR, and is now fixed.

Signed-off-by: Ronen Friedman <[email protected]>
@ronen-fr

Copy link
Copy Markdown
Contributor Author

The failure was related (a PG flag being reset to early).
Fixed now.

@ronen-fr

Copy link
Copy Markdown
Contributor Author

jenkins retest this please

@ronen-fr

Copy link
Copy Markdown
Contributor Author

jenkins test api

@ronen-fr

ronen-fr commented Nov 1, 2023

Copy link
Copy Markdown
Contributor Author

@ljflores @yuriw I will be running some more of my own tests before merging.
Thanks for your help.

@yuriw yuriw removed the needs-qa label Nov 1, 2023
@ronen-fr
ronen-fr merged commit 878fe82 into ceph:main Nov 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants