Skip to content

SOLR-17187: make replica poll interval configurable #3144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
May 16, 2025

Conversation

cpoerschke
Copy link
Contributor

Continuation of @tboeghk's #2316 as a new pull request since pushing to the PR's branch is not possible (due to org vs. individual repo fork).

  • merged in latest origin/main
  • added (minimal) Solr Ref Guide update
  • added solr/CHANGES.txt entry

https://issues.apache.org/jira/browse/SOLR-17187

tboeghk and others added 10 commits February 22, 2024 13:53
A supplied `commitPollInterval` in `updateHandler` this has precendence over one calculated from hard/soft commit settings
Also add tests for retrieving and selecting the commit interval
Co-authored-by: Christine Poerschke <[email protected]>
Co-authored-by: Christine Poerschke <[email protected]>
Co-authored-by: Christine Poerschke <[email protected]>
- Move poll interval determination into single method
Resolved Conflicts:
	solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java
@github-actions github-actions bot added documentation Improvements or additions to documentation tests cat:cloud labels Jan 29, 2025
@cpoerschke cpoerschke marked this pull request as ready for review January 29, 2025 17:01
Copy link
Contributor

@epugh epugh left a comment

Choose a reason for hiding this comment

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

Thanks for picking up this PR that has languished for a long time!

pollIntervalStr = calculatedPollIntervalString;
}
final SolrConfig.UpdateHandlerInfo uinfo = core.getSolrConfig().getUpdateHandlerInfo();
final String pollIntervalStr = determinePollInterval(uinfo);
Copy link
Contributor

Choose a reason for hiding this comment

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

this is nicer.

*/
public static String determinePollInterval(SolrConfig.UpdateHandlerInfo uinfo) {
int hardCommitMaxTime = uinfo.autoCommmitMaxTime;
int softCommitMaxTime = uinfo.autoSoftCommmitMaxTime;
boolean hardCommitNewSearcher = uinfo.openSearcher;
String pollIntervalStr = null;
if (hardCommitMaxTime != -1) {
String customCommitPollInterval = uinfo.commitPollInterval;
Copy link
Contributor

Choose a reason for hiding this comment

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

with the comment about the never null, do we need some sort of assert in here?

Copy link
Contributor

Choose a reason for hiding this comment

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

I've added an assert right before this method returns; think that should be sufficient?

@@ -1485,7 +1486,8 @@ private Long readIntervalMs(String interval) {
return TimeUnit.MILLISECONDS.convert(readIntervalNs(interval), TimeUnit.NANOSECONDS);
}

private Long readIntervalNs(String interval) {
@VisibleForTesting
public static Long readIntervalNs(String interval) {
Copy link
Contributor

Choose a reason for hiding this comment

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

do you need the public if you have @VisibleForTesting, or is that just to remind us why it's public?

Copy link
Contributor

Choose a reason for hiding this comment

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

indeed; it explains why it's more open than it otherwise needs to be

Copy link
Contributor

Choose a reason for hiding this comment

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

[Q] Is the @VisibleForTesting explanation accurate though? Maybe we do call it in our tests, but we also call it in ReplicateFromLeader

Unless there's something I'm missing we should probably nuke the annotation.

private String jettyTestMode;

@Before
public void setUp() {
Copy link
Contributor

Choose a reason for hiding this comment

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

don't we have some sort of Rule thing these days for this? @dsmiley ???

Copy link
Contributor

Choose a reason for hiding this comment

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

Indeed we do. Firstly, all Solr tests ought to extend SolrTestCase, at least indirectly. This test doesn't; it should be modified. Secondly, STCJ4 includes:

  @Rule public TestRule solrTestRules = RuleChain.outerRule(new SystemPropertiesRestoreRule());

That obsoletes the setup & tearDown here.

So for now, I suggest removing the setup & teardown here and subclass STCJ4. It's a TODO for me in my work on making SolrTestCase a better base class to transition that line from STCJ4 to STC.

@@ -62,6 +62,8 @@ It is recommended that this be set for as long as is reasonable given the applic
A hard commit means that, if a server crashes, Solr will know exactly where your data was stored; a soft commit means that the data is stored, but the location information isn't yet stored.
The tradeoff is that a soft commit gives you faster visibility because it's not waiting for background merges to finish.

In a TLOG/PULL replica setup, the commit configuration also influences the interval at which the replica is polling the shard leader. You may optionally configure a custom `commitPollInterval`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Please start new sentences on new lines. Not sure if this style choice is stated somewhere. Goal is reducing diffs and reducing need for line wrap.

Copy link
Contributor

Choose a reason for hiding this comment

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

Fixed.

@@ -1485,7 +1486,8 @@ private Long readIntervalMs(String interval) {
return TimeUnit.MILLISECONDS.convert(readIntervalNs(interval), TimeUnit.NANOSECONDS);
}

private Long readIntervalNs(String interval) {
@VisibleForTesting
public static Long readIntervalNs(String interval) {
Copy link
Contributor

Choose a reason for hiding this comment

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

indeed; it explains why it's more open than it otherwise needs to be

private String jettyTestMode;

@Before
public void setUp() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Indeed we do. Firstly, all Solr tests ought to extend SolrTestCase, at least indirectly. This test doesn't; it should be modified. Secondly, STCJ4 includes:

  @Rule public TestRule solrTestRules = RuleChain.outerRule(new SystemPropertiesRestoreRule());

That obsoletes the setup & tearDown here.

So for now, I suggest removing the setup & teardown here and subclass STCJ4. It's a TODO for me in my work on making SolrTestCase a better base class to transition that line from STCJ4 to STC.

Copy link

github-actions bot commented Apr 3, 2025

This PR has had no activity for 60 days and is now labeled as stale. Any new activity will remove the stale label. To attract more reviewers, please tag people who might be familiar with the code area and/or notify the [email protected] mailing list. To exempt this PR from being marked as stale, make it a draft PR or add the label "exempt-stale". If left unattended, this PR will be closed after another 60 days of inactivity. Thank you for your contribution!

@github-actions github-actions bot added the stale PR not updated in 60 days label Apr 3, 2025
@epugh
Copy link
Contributor

epugh commented Apr 3, 2025

Looks like most of the work has been done.... @cpoerschke do you want to take this over the finish line, or I'm happy to...

@github-actions github-actions bot removed the stale PR not updated in 60 days label Apr 4, 2025
@cpoerschke
Copy link
Contributor Author

Looks like most of the work has been done.... @cpoerschke do you want to take this over the finish line, or I'm happy to...

Thanks @epugh! Yes, please feel free to continue with this.

Copy link
Contributor

@gerlowskija gerlowskija left a comment

Choose a reason for hiding this comment

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

Took the liberty of tackling the last few TODOs here. If either of you two (@cpoerschke , @epugh ) want to take this back over, go for it. Otherwise I'll aim to commit in the next few days.

Thanks for getting the ball rolling on this @tboeghk - apologies it's taken a bit to get merged.

@@ -1485,7 +1486,8 @@ private Long readIntervalMs(String interval) {
return TimeUnit.MILLISECONDS.convert(readIntervalNs(interval), TimeUnit.NANOSECONDS);
}

private Long readIntervalNs(String interval) {
@VisibleForTesting
public static Long readIntervalNs(String interval) {
Copy link
Contributor

Choose a reason for hiding this comment

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

[Q] Is the @VisibleForTesting explanation accurate though? Maybe we do call it in our tests, but we also call it in ReplicateFromLeader

Unless there's something I'm missing we should probably nuke the annotation.

*/
public static String determinePollInterval(SolrConfig.UpdateHandlerInfo uinfo) {
int hardCommitMaxTime = uinfo.autoCommmitMaxTime;
int softCommitMaxTime = uinfo.autoSoftCommmitMaxTime;
boolean hardCommitNewSearcher = uinfo.openSearcher;
String pollIntervalStr = null;
if (hardCommitMaxTime != -1) {
String customCommitPollInterval = uinfo.commitPollInterval;
Copy link
Contributor

Choose a reason for hiding this comment

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

I've added an assert right before this method returns; think that should be sufficient?

@@ -62,6 +62,8 @@ It is recommended that this be set for as long as is reasonable given the applic
A hard commit means that, if a server crashes, Solr will know exactly where your data was stored; a soft commit means that the data is stored, but the location information isn't yet stored.
The tradeoff is that a soft commit gives you faster visibility because it's not waiting for background merges to finish.

In a TLOG/PULL replica setup, the commit configuration also influences the interval at which the replica is polling the shard leader. You may optionally configure a custom `commitPollInterval`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Fixed.

@gerlowskija
Copy link
Contributor

(Tests, check, and precommit pass locally. I'll add a CHANGES.txt entry right before merge.)

@gerlowskija gerlowskija merged commit 2b1fbc1 into apache:main May 16, 2025
1 of 3 checks passed
gerlowskija added a commit that referenced this pull request May 16, 2025
A supplied `commitPollInterval` in `updateHandler` now takes
precedence over the default (which is calculated based on
hard/soft commit settings).

---------
Co-authored-by: Torsten Bøgh Köster <[email protected]>
Co-authored-by: Torsten Bøgh Köster <[email protected]>
Co-authored-by: Christine Poerschke <[email protected]>
Co-authored-by: Jason Gerlowski <[email protected]>
aruggero pushed a commit to SeaseLtd/solr that referenced this pull request May 19, 2025
A supplied `commitPollInterval` in `updateHandler` now takes
precedence over the default (which is calculated based on
hard/soft commit settings).

---------
Co-authored-by: Torsten Bøgh Köster <[email protected]>
Co-authored-by: Torsten Bøgh Köster <[email protected]>
Co-authored-by: Christine Poerschke <[email protected]>
Co-authored-by: Jason Gerlowski <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cat:cloud documentation Improvements or additions to documentation tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants