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

IGNITE-18534 The WalWritingRate metric is not calculated when walMode is LOG_ONLY or BACKGROUND #10508

Merged
merged 3 commits into from
Mar 1, 2023

Conversation

luchnikovbsk
Copy link
Contributor

@luchnikovbsk luchnikovbsk commented Jan 31, 2023

Moved the calculation of the metric to another place, which will work in any WalMode.
The result of running the reproducer before and after fixing in https://issues.apache.org/jira/browse/IGNITE-18534.
A commit with a reproducer is not for merging.

The Contribution Checklist

  • There is a single JIRA ticket related to the pull request.
  • The web-link to the pull request is attached to the JIRA ticket.
  • The JIRA ticket has the Patch Available state.
  • The pull request body describes changes that have been made.
    The description explains WHAT and WHY was made instead of HOW.
  • The pull request title is treated as the final commit message.
    The following pattern must be used: IGNITE-XXXX Change summary where XXXX - number of JIRA issue.
  • A reviewer has been mentioned through the JIRA comments
    (see the Maintainers list)
  • The pull request has been checked by the Teamcity Bot and
    the green visa attached to the JIRA ticket (see TC.Bot: Check PR)

Notes

If you need any help, please email dev@ignite.apache.org or ask anу advice on http://asf.slack.com #ignite channel.

.setWalArchivePath(DFLT_WAL_PATH)
.setWalSegments(10)
.setWalSegmentSize((int)(1 * MULTIPLICATOR))
.setMaxWalArchiveSize(20 * MULTIPLICATOR)
Copy link
Contributor

@zstan zstan Jan 31, 2023

Choose a reason for hiding this comment

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

20 * MB more clear than your proposal, i suppose.

Copy link
Contributor Author

@luchnikovbsk luchnikovbsk Jan 31, 2023

Choose a reason for hiding this comment

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

Ok, MULTIPLICATOR i use for debug, this is not the final PR, this is a PR for questions.

  1. Is this a good fix?
  2. Write a test that will check the correctness of the calculation of this metric?

The current test is a reproducer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@luchnikovbsk luchnikovbsk force-pushed the IGNITE-18534_master branch 4 times, most recently from bbab9ed to dd966fa Compare February 1, 2023 11:53
List<Long> walWritingRates = new ArrayList<>();

long lastSegment = walMgr(ignite).currentSegment() + MAX_SEGMENTS;
long prewSegment = walMgr(ignite).currentSegment();
Copy link
Contributor

Choose a reason for hiding this comment

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

typo: prew -> prev

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done 0_o

*/
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
//for debug
LogExporterSpi exporterSpi = new LogExporterSpi();
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems we can remove this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

}

/**
* {@inheritDoc}
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be one line comment like in other places.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

}

/**
* {@inheritDoc}
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be one line comment like in other places.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

/**
* Small report for debug.
*/
private static final Map<String, List<Long>> report = new HashMap<>();
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems this can be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

/**
* MULTIPLICATOR.
*/
private static final long MULTIPLICATOR = U.MB;
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use U.MB everywhere in the test without additional review.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

deleted it

/**
* Тumber of segments.
*/
private static final int MAX_SEGMENTS = 20;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really need this much segements in the test?

Copy link
Contributor Author

@luchnikovbsk luchnikovbsk Feb 27, 2023

Choose a reason for hiding this comment

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

In the test, the value of the metric is taken after the segment is filled.
Decreased to 1 to speed up test execution.
It seemed more correct to get the value of the metric by filling the segment than by reaching some time, for example, 1 second after the start of recording.

/**
* {@inheritDoc}
*/
@Override protected void afterTestsStopped() throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

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

this method can be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@luchnikovbsk luchnikovbsk force-pushed the IGNITE-18534_master branch 2 times, most recently from 8638ceb to 667018a Compare February 27, 2023 10:05
@luchnikovbsk luchnikovbsk force-pushed the IGNITE-18534_master branch 4 times, most recently from 8ae221c to baa46c0 Compare February 27, 2023 11:57
new DataStorageConfiguration()
.setMetricsEnabled(true)
.setWalArchivePath(DFLT_WAL_PATH)
.setWalSegmentSize(1 * 1024 * 1024)
Copy link
Contributor

Choose a reason for hiding this comment

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

1 * 1024 * 1024 -> U.MB

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
return super.getConfiguration(igniteInstanceName)
.setCacheConfiguration(new CacheConfiguration<>(DEFAULT_CACHE_NAME))
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be removed and replaced with ignite.getOrCreateCache

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

AtomicLong key = new AtomicLong();
List<Long> walWritingRates = new ArrayList<>();

long lastSegment = walMgr(ignite).currentSegment() + 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's extract walMgr(ignite) into variable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

deleted it

AtomicLong key = new AtomicLong();
List<Long> walWritingRates = new ArrayList<>();

long lastSegment = walMgr(ignite).currentSegment() + 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems we don't need to care about segments here.
Le'ts just do the following:

long k = 0;
for (; k<100; k++) {
    long[] arr = new long[64];
    Arrays.fill(arr, k);

    ignite.getOrCreateCache(DEFAULT_CACHE_NAME).put(key, arr);

    Long writingRate =  metricRegistry(ignite.name(), "io", "datastorage").getAttribute("WalWritingRate");
    if (writingRate != null && writingRate > 0)
        break;
}

assertTrue(k < 100);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

.setDataStorageConfiguration(
new DataStorageConfiguration()
.setMetricsEnabled(true)
.setWalArchivePath(DFLT_WAL_PATH)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really need WalArchivePath for this test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, deleted

public class IoDatastorageMetricsTest extends GridCommonAbstractTest {

/**
* WALMode.
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be oneline comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

public WALMode walMode;

/**
* WALMode values.
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be oneline comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

import static org.junit.Assert.assertNotEquals;

/**
* The test shows that the WalWritingRate metric is not calculated when walMode is in (LOG_ONLY, BACKGROUND).
Copy link
Contributor

Choose a reason for hiding this comment

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

Test checks that WalWritingRate metric updated in all WAL modes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

* The test shows that the WalWritingRate metric is not calculated when walMode in all modes.
*/
@Test
public void WalWritingRate() throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please, rename WalWritingRate to testWalWritingRate or walWritingRate.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done


ignite.getOrCreateCache(DEFAULT_CACHE_NAME).put(i, arr);

writingRate = (long)metricRegistry(ignite.name(), "io", "datastorage").getAttribute("WalWritingRate");
Copy link
Contributor

Choose a reason for hiding this comment

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

Empty line after this required.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@luchnikovbsk luchnikovbsk force-pushed the IGNITE-18534_master branch 3 times, most recently from 5dde17e to f6992ef Compare February 28, 2023 12:59
@nizhikov nizhikov merged commit 9db91c4 into apache:master Mar 1, 2023
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