Skip to content

Conversation

ekaterinadimitrova2
Copy link

What is the issue

...
We want to be able to enable/disable IndexMetrics

What does this PR fix and why was it fixed

...
We add a flag to be able to do that - SAI_INDEX_METRICS_ENABLED("cassandra.sai.metrics.index.enabled", "true")
Also, added some simple unit tests to test the new parameter.

Copy link

Checklist before you submit for review

  • This PR adheres to the Definition of Done
  • Make sure there is a PR in the CNDB project updating the Converged Cassandra version
  • Use NoSpamLogger for log lines that may appear frequently in the logs
  • Verify test results on Butler
  • Test coverage for new/modified code is > 80%
  • Proper code formatting
  • Proper title for each commit staring with the project-issue number, like CNDB-1234
  • Each commit has a meaningful description
  • Each commit is not very long and contains related changes
  • Renames, moves and reformatting are in distinct commits
  • All new files should contain the DataStax copyright header instead of the Apache License one

Comment on lines 355 to 356
if (indexContext.getIndexMetrics() != null)
indexContext.getIndexMetrics().segmentFlushErrors.inc();

Choose a reason for hiding this comment

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

There is a bunch of (probably harmless) dereferences like this one, and no external clue about IndexContext#getIndexMetrics being nullable. I think we could do that method return an Optional:

public Optional<IndexMetrics> getIndexMetrics()
{
    return Optional.ofNullable(indexMetrics);
}

and then use it this way:

Suggested change
if (indexContext.getIndexMetrics() != null)
indexContext.getIndexMetrics().segmentFlushErrors.inc();
indexContext.getIndexMetrics().ifPresent(m -> m.segmentFlushErrors.inc());

Choose a reason for hiding this comment

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

Oh you are totally right. I was thinking about that and then forgot to fix it :( Thanks!

Choose a reason for hiding this comment

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

+1

}
}

private void assertMetricDoesNotExist(ObjectName name, String metricName)

Choose a reason for hiding this comment

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

We could use the inherited SAITester#assertMetricDoesNotExist. And since we have that method there, maybe we could move assertMetricExists to SAITester too?

@ekaterinadimitrova2
Copy link
Author

CI finished ok, but Sonar complained about a missing test (one of the metrics never had a test, but because now we touched the code...), so I added that, removed a few imports I saw we don't need, and fixed one more warning from Sonar. That should be a wrap. @adelapena , @pkolaczk , please check the latest changes that you agree with everything. In the meantime I will update and run CI for the other PR.

Copy link

@cassci-bot
Copy link

❌ Build ds-cassandra-pr-gate/PR-2025 rejected by Butler


2 regressions found
See build details here


Found 2 new test failures

Test Explanation Runs Upstream
o.a.c.index.sai.cql.datamodels.QueryWriteLifecycleWithCompositePartitionKeyTest.testWriteLifecycle[ca] <span title="The test is FAILING on feature but PASSING on upstream:
• Feature branch: FAILING in the recent 2 >= 2 minimum runs (1 actual failures, 1 missing/skipped) in 2 builds (1 to 3)
• Upstream branch: PASSING in the last 7 runs in 7 builds (1578 to 1587)">REGRESSION 🔴 0 / 7
o.a.c.metrics.TopFrequencySamplerTest.testSamplerSingleInsertionsEqualMulti (compression) <span title="The test is FLAKY on feature and PASSING on upstream:
• Feature branch: FLAKY because there are 1 passing, 1 failing, 0 missing, and 0 skipped runs in the last 2 runs in 2 builds (1 to 3)
• Upstream branch: PASSING in the last 7 runs in 7 builds (1578 to 1587)">REGRESSION 🔴🔵 0 / 7

No known test failures found

@ekaterinadimitrova2
Copy link
Author

testWriteLifecycle - known issue from #15218
testSamplerSingleInsertionsEqualMulti - it doesn't fail for me locally, and it doesn't seem related to me, so I suggest we open follow up ticket

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.

4 participants