-
Notifications
You must be signed in to change notification settings - Fork 809
SOLR-18083: Fix replication and other general operations in readOnly mode #4081
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
base: main
Are you sure you want to change the base?
Changes from all commits
61d0b63
3f6cdf8
5cffa98
42fa1da
b1cba8b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # See https://github.com/apache/solr/blob/main/dev-docs/changelog.adoc | ||
| title: Fix normal operation errors for readOnly collections | ||
| type: other # added, changed, fixed, deprecated, removed, dependency_update, security, other | ||
| authors: | ||
| - name: Houston Putman | ||
| nick: HoustonPutman | ||
| links: | ||
| - name: SOLR-18083 | ||
| url: https://issues.apache.org/jira/browse/SOLR-18083 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2476,7 +2476,7 @@ public RefCounted<SolrIndexSearcher> openNewSearcher( | |
| true, | ||
| directoryFactory); | ||
| } else { | ||
| RefCounted<IndexWriter> writer = getSolrCoreState().getIndexWriter(this); | ||
| RefCounted<IndexWriter> writer = getSolrCoreState().getIndexWriter(this, true); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why? |
||
| DirectoryReader newReader = null; | ||
| try { | ||
| newReader = indexReaderFactory.newReader(writer.get(), this); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,6 +39,7 @@ public class CommitUpdateCommand extends UpdateCommand { | |
| public boolean expungeDeletes = false; | ||
| public boolean softCommit = false; | ||
| public boolean prepareCommit = false; | ||
| public boolean failOnReadOnly = true; // fail the commit if the core or collection is readOnly | ||
|
|
||
| /** | ||
| * User provided commit data. Can be let to null if there is none. It is possible to commit this | ||
|
|
@@ -97,7 +98,9 @@ public String toString() { | |
| .append(",softCommit=") | ||
| .append(softCommit) | ||
| .append(",prepareCommit=") | ||
| .append(prepareCommit); | ||
| .append(prepareCommit) | ||
| .append(",failOnReadOnly=") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we do this conditionally please? |
||
| .append(failOnReadOnly); | ||
| if (commitData != null) { | ||
| sb.append(",commitData=").append(commitData); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -178,7 +178,19 @@ public void deregisterInFlightUpdate() { | |
| * | ||
| * @throws IOException If there is a low-level I/O error. | ||
| */ | ||
| public abstract RefCounted<IndexWriter> getIndexWriter(SolrCore core) throws IOException; | ||
| public RefCounted<IndexWriter> getIndexWriter(SolrCore core) throws IOException { | ||
| return getIndexWriter(core, false); | ||
| } | ||
|
|
||
| /** | ||
| * Get the current IndexWriter. If a new IndexWriter must be created, use the settings from the | ||
| * given {@link SolrCore}. Be very careful using the {@code readOnlyCompatible} flag, by default | ||
| * it should be false if the returned indexWriter will be used for writing. | ||
| * | ||
| * @throws IOException If there is a low-level I/O error. | ||
| */ | ||
| public abstract RefCounted<IndexWriter> getIndexWriter(SolrCore core, boolean readOnlyCompatible) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| throws IOException; | ||
|
|
||
| /** | ||
| * Rollback the current IndexWriter. When creating the new IndexWriter use the settings from the | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -161,7 +161,13 @@ public void processCommit(CommitUpdateCommand cmd) throws IOException { | |
| assert TestInjection.injectFailUpdateRequests(); | ||
|
|
||
| if (isReadOnly()) { | ||
| throw new SolrException(ErrorCode.FORBIDDEN, "Collection " + collection + " is read-only."); | ||
| if (cmd.failOnReadOnly) { | ||
| throw new SolrException(ErrorCode.FORBIDDEN, "Collection " + collection + " is read-only."); | ||
| } else { | ||
| // Committing on a readOnly core/collection is a no-op, since the core was committed when | ||
| // becoming read-only and hasn't had any updates since. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could we actually assert this -- like the same check Solr does to avoid committing if there's nothing to do? |
||
| return; | ||
| } | ||
| } | ||
|
|
||
| List<SolrCmdDistributor.Node> nodes = null; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[0] From description in the associated JIRA, it seems like this change should fix a handful of specific user-visible bugs (e.g. allowing them to come up on a node-restart?). Wdyt of reworking the changelog to highlight that.
The existing description feels a little inscrutable (or overly general) for the average user?