Skip to content
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

SOLR-16852: Let backups have custom key/values #1739

Merged
merged 5 commits into from
Oct 3, 2023

Conversation

tflobbe
Copy link
Member

@tflobbe tflobbe commented Jun 29, 2023

Currently backups have some properties attached such as configName, collectionAlias, indexVersion, etc. It would be useful to allow custom properties/annotations to add some information coming from the process that triggers the backup. For example, say you have a process that consumes from a queue, adds documents to Solr and then triggers a backup command, the backup could include the queue offset at the time of triggering the backup so that the application could potentially continue processing from such offset upon restore.

@tflobbe
Copy link
Member Author

tflobbe commented Jun 29, 2023

I'm working on the docs for this change. Will update this PR. Done

"conf1",
Map.of("foo", "bar", "aaa", "bbb"));
try (BackupRepository repository =
cluster.getJettySolrRunner(0).getCoreContainer().newBackupRepository(BACKUP_REPO_NAME)) {
Copy link

Choose a reason for hiding this comment

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

15% of developers fix this issue

NULL_DEREFERENCE: object returned by org.apache.solr.cloud.api.collections.AbstractIncrementalBackupTest.cluster.getJettySolrRunner(0).getCoreContainer() could be null and is dereferenced at line 472.


ℹ️ Expand to see all @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.

"conf1",
Map.of("foo", "bar", "aaa", "bbb"));
try (BackupRepository repository =
cluster.getJettySolrRunner(0).getCoreContainer().newBackupRepository(BACKUP_REPO_NAME)) {
Copy link

Choose a reason for hiding this comment

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

7% of developers fix this issue

NULLPTR_DEREFERENCE: CoreContainer JettySolrRunner.getCoreContainer() could be null (from the call to JettySolrRunner.getCoreContainer() on line 472) and is dereferenced.


ℹ️ Expand to see all @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.

@@ -550,7 +582,7 @@ private void indexDocs(String collectionName, int numDocs, boolean useUUID) thro
log.info("Indexed {} docs to collection: {}", numDocs, collectionName);
}

private int indexDocs(String collectionName, boolean useUUID) throws Exception {
protected int indexDocs(String collectionName, boolean useUUID) throws Exception {
Random random =
Copy link

Choose a reason for hiding this comment

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

17% of developers fix this issue

PREDICTABLE_RANDOM: This random generator (java.util.Random) is predictable


ℹ️ Expand to see all @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.

@@ -550,7 +582,7 @@ private void indexDocs(String collectionName, int numDocs, boolean useUUID) thro
Copy link

Choose a reason for hiding this comment

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

14% of developers fix this issue

NULL_DEREFERENCE: object leader last assigned on line 493 could be null and is dereferenced by call to getReplicaJetty(...) at line 494.


ℹ️ Expand to see all @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.

@@ -550,7 +582,7 @@ private void indexDocs(String collectionName, int numDocs, boolean useUUID) thro
Copy link

Choose a reason for hiding this comment

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

7% of developers fix this issue

NULLPTR_DEREFERENCE: leader could be null (from the call to Slice.getLeader() on line 493) and is dereferenced in the call to MiniSolrCloudCluster.getReplicaJetty(...).


ℹ️ Expand to see all @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.

Copy link
Contributor

@HoustonPutman HoustonPutman left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@tflobbe
Copy link
Member Author

tflobbe commented Sep 25, 2023

@dsmiley, Any concerns with this approach, given the discussion in the Jira issue?

if (entryKey.startsWith(EXTRA_PROPERTY_PREFIX)) {
extraProperties.put(
entryKey.substring(EXTRA_PROPERTY_PREFIX.length()), String.valueOf(value));
props.remove(key);
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think you can iterate & remove in the same loop -- ConcurrentModificationException ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Properties are backed by a ConcurrentHashMap, so it should be OK

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, okay, although depending on internal details :-/. Another alternative is using props.entrySet().removeIf
Any way, doesn't matter much to me.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I agree that's cleaner. I'll update

properties.put("indexFileCount", String.valueOf(indexFileCount));
properties.put(BackupManager.END_TIME_PROP, Instant.now().toString());
properties.store(propsWriter, "Backup properties file");
Properties propertiesCopy = (Properties) properties.clone();
Copy link
Contributor

Choose a reason for hiding this comment

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

nice; it was sketchy previously, modifying the field properties here

@tflobbe tflobbe merged commit f88891e into apache:main Oct 3, 2023
3 checks passed
@tflobbe tflobbe deleted the backup-props branch October 3, 2023 22:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants