Skip to content

SAMZA-2297: InMemorySystemAdmin offsets are off-by-one in some cases - #1133

Merged
cameronlee314 merged 4 commits into
apache:masterfrom
cameronlee314:in_memory_system_empty
Aug 13, 2019
Merged

cameronlee314 merged 4 commits into
apache:masterfrom
cameronlee314:in_memory_system_empty

Conversation

@cameronlee314

Copy link
Copy Markdown
Contributor

Added unit tests.
Ran a local build to make sure existing usages are still working.
Changed TestSamzaSqlEndToEnd.testEndToEndStreamTableRightJoin (which uses intermediate streams) to use in-memory system. Failed before this change, succeeded after this change.

@Sanil15 Sanil15 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the patch

@mynameborat mynameborat left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you for the fix and unit tests :)

@cameronlee314
cameronlee314 merged commit 37de270 into apache:master Aug 13, 2019
String newestOffset = String.valueOf(entry.getValue().size());
String upcomingOffset = String.valueOf(entry.getValue().size() + 1);
List<IncomingMessageEnvelope> messages = entry.getValue();
String oldestOffset = messages.isEmpty() ? null : "0";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@cameronlee314 Any objection to defaulting this to "0" instead of null in case the SSP is empty? This is consistent with the behavior for Kafka as well where an empty SSP returns (0, null, 0) as (oldest, newest, upcoming) offsets. Will also remove the need to handle nulls in Consumer#register.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

SystemStreamMetadata.SystemStreamPartitionMetadata.getOldestOffset is documented with "A null value means the stream is empty". That's why I used null here. Does that mean that Kafka is not following the API?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Seems like it. https://github.com/apache/samza/blob/master/samza-kafka/src/main/java/org/apache/samza/system/kafka/KafkaSystemAdmin.java#L403

I need to rely on this information during changelog restore for transactional state. It doesn't make sense to change the behavior for Kafka as part of the transactional state changes. Since InMemoryStore is used as a changelog for tests, I'll relax the assertion/validation for non-null starting offsets in the restore path. Thanks for the pointer.

@cameronlee314
cameronlee314 deleted the in_memory_system_empty branch October 4, 2019 21:47
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