Skip to content

Comments

Transactional State [2/5]: Added a ChangelogSSPIterator API#1161

Merged
prateekm merged 1 commit intoapache:masterfrom
prateekm:alo-changelog-ssp-iterator-api
Oct 2, 2019
Merged

Transactional State [2/5]: Added a ChangelogSSPIterator API#1161
prateekm merged 1 commit intoapache:masterfrom
prateekm:alo-changelog-ssp-iterator-api

Conversation

@prateekm
Copy link
Contributor

@prateekm prateekm commented Sep 17, 2019

This PR changes the KeyValueStorageEngine restore API and implementation to take a new ChangelogSSPIterator instead of a plain Iterator.

The new ChangelogSSPIterator is similar to the existing SystemStreamPartitionIterator with the following differences:

  1. This new iterator has 2 modes: Restore and Trim.
  2. It takes an endingOffset during construction. The mode changes from Restore to Trim during iteration if the current message offset is greater than the ending offset (and trim mode is enabled).
  3. Does not check for end of stream since it isn't applicable to changelog topics.

For supporting transactional state, we only restore changelog messages up to the changelog SSP offset in the checkpoint topic. Any messages after this 'checkpointed changelog offset' are trimmed by overwriting them with the current store value. When used in conjunction with an appropriate 'min.compaction.lag.ms' configuration for the Kafka changelog topic, this ensures that on container restart any store contents are consistent with the last input checkpoints and do not reflect any newer changes.

@prateekm prateekm force-pushed the alo-changelog-ssp-iterator-api branch from bd53e0f to f59bc19 Compare September 17, 2019 23:20
@prateekm prateekm changed the title [WIP] [2/6] Transactional State: Added a ChangelogSSPIterator API Transactional State [2/5]: Added a ChangelogSSPIterator API Sep 18, 2019
Copy link

@bharathkumarasubramanian bharathkumarasubramanian left a comment

Choose a reason for hiding this comment

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

Mostly minor comments/questions.
It should be fine to have them addressed as part of the 5/5 PR to make rebase easier.

val mode = iterator.getMode

if (mode.equals(ChangelogSSPIterator.Mode.RESTORE)) {
batch.add(new Entry(keyBytes, valBytes))

Choose a reason for hiding this comment

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

Should we throw an exception here if the iterator transitioned to RESTORE after being in TRIM or is it something we can guarantee as part of the ChangelogIterator?

Copy link
Contributor Author

@prateekm prateekm Oct 2, 2019

Choose a reason for hiding this comment

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

Will fix in PR 5/5. SAMZA-2337 to track.

if (!lastBatchFlushed) {
info(restoredMessages + " total entries restored for store: " + storeName + " in directory: " + storeDir.toString + ".")
if (batch.size > 0) {
doPutAll(rawStore, batch)

Choose a reason for hiding this comment

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

do we need to clear the batch here just to be safe?

Copy link
Contributor Author

@prateekm prateekm Oct 2, 2019

Choose a reason for hiding this comment

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

Will update in PR 5. SAMZA-2337 to track.

if (batch.size > 0) {
doPutAll(rawStore, batch)
}
// flush the store and the changelog producer

Choose a reason for hiding this comment

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

This isn't required for old code path. However, should this be a blocker instead of high for new code path?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We do a task commit after the restore is complete and before we start processing. That will flush all producers (incl. changelog producer). So not a blocker.

@@ -142,12 +142,22 @@ class TestKeyValueStorageEngine {
@Test
def testRestoreMetrics(): Unit = {

Choose a reason for hiding this comment

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

maybe add a test case to ensure the transition from TRIM to RESTORE doesn't happen.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will add in PR 5.

Copy link
Contributor

@mynameborat mynameborat left a comment

Choose a reason for hiding this comment

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

Left comments w/ my personal account by mistake.
Approving w/ my apache account.

@prateekm prateekm force-pushed the alo-changelog-ssp-iterator-api branch from df7b992 to 0e52bb1 Compare October 2, 2019 01:25
@prateekm prateekm merged commit 3e5ede6 into apache:master Oct 2, 2019
@prateekm prateekm deleted the alo-changelog-ssp-iterator-api branch March 6, 2023 18:55
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