Skip to content

Conversation

@Jackie-Jiang
Copy link
Contributor

In segment metadata and index map, store columns in alphabetical order so that the result is deterministic.
This is very important to ensure segment generated from the same data has the same CRC. When multiple servers consume from the same stream, it is critical that all segments generated has the same CRC, or server will need to download a new segment copy when restart due to CRC mismatch. This can cause significant longer server restart time.

Release Notes

Segment generated before/after this PR will have different CRC, so during the upgrade, we might get segments with different CRC from old and new consuming server. For the segment consumed during the upgrade, some downloads might be needed.

@Jackie-Jiang Jackie-Jiang added release-notes Referenced by PRs that need attention when compiling the next release notes bugfix labels Mar 23, 2023
@Jackie-Jiang Jackie-Jiang force-pushed the metadata_deterministic_order branch from 7242a4c to 2c6042b Compare March 23, 2023 23:09
@Jackie-Jiang Jackie-Jiang force-pushed the metadata_deterministic_order branch 3 times, most recently from dddcf7d to ce87ddb Compare March 24, 2023 01:00
Copy link
Contributor

@61yao 61yao Mar 24, 2023

Choose a reason for hiding this comment

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

Does this test different column orders give same CRC?

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, different column order will give different CRC. This test is used to make sure the order is always the same

@Jackie-Jiang Jackie-Jiang force-pushed the metadata_deterministic_order branch from ce87ddb to 3aa78db Compare March 24, 2023 19:03
@Jackie-Jiang Jackie-Jiang force-pushed the metadata_deterministic_order branch 2 times, most recently from 056ece1 to d9b574c Compare March 28, 2023 06:31
@codecov-commenter
Copy link

codecov-commenter commented Mar 28, 2023

Codecov Report

Merging #10468 (13457cc) into master (81e02df) will increase coverage by 4.70%.
The diff coverage is 68.65%.

@@             Coverage Diff              @@
##             master   #10468      +/-   ##
============================================
+ Coverage     64.10%   68.80%   +4.70%     
- Complexity     6091     6116      +25     
============================================
  Files          2036     2090      +54     
  Lines        109727   112169    +2442     
  Branches      16782    17080     +298     
============================================
+ Hits          70338    77180    +6842     
+ Misses        34236    29505    -4731     
- Partials       5153     5484     +331     
Flag Coverage Δ
integration2 24.50% <0.00%> (?)
unittests1 67.85% <68.65%> (-0.01%) ⬇️
unittests2 13.96% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...inputformat/avro/AvroIngestionSchemaValidator.java 0.00% <0.00%> (ø)
...ment/creator/impl/SegmentColumnarIndexCreator.java 79.96% <ø> (ø)
...org/apache/pinot/segment/local/utils/CrcUtils.java 96.29% <ø> (-1.44%) ⬇️
.../org/apache/pinot/segment/spi/SegmentMetadata.java 66.66% <ø> (ø)
...loader/defaultcolumn/BaseDefaultColumnHandler.java 57.25% <50.00%> (-0.72%) ⬇️
...egment/spi/index/metadata/SegmentMetadataImpl.java 75.52% <50.00%> (ø)
.../columnminmaxvalue/ColumnMinMaxValueGenerator.java 70.88% <66.66%> (-3.75%) ⬇️
...he/pinot/segment/local/utils/TableConfigUtils.java 68.67% <75.00%> (+0.18%) ⬆️
...rc/main/java/org/apache/pinot/spi/data/Schema.java 73.37% <81.25%> (-0.55%) ⬇️
...l/realtime/converter/RealtimeSegmentConverter.java 79.62% <100.00%> (+0.38%) ⬆️
... and 4 more

... and 401 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@Jackie-Jiang Jackie-Jiang force-pushed the metadata_deterministic_order branch from 3a29923 to 829cea0 Compare March 28, 2023 20:21
@Jackie-Jiang Jackie-Jiang force-pushed the metadata_deterministic_order branch from 829cea0 to 13457cc Compare March 28, 2023 21:04
String getEndOffset();

default Set<String> getAllColumns() {
default NavigableSet<String> getAllColumns() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shall we directly use TreeSet instead of NavigableSet if there is no other implementation expected .

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is an ordered set, but not a TreeSet because the key set of the TreeMap is not a TreeSet

.isEqual(_primaryKeyColumns, that._primaryKeyColumns) && EqualityUtils
.isEqual(_hasJSONColumn, that._hasJSONColumn);
//@formatter:off
return EqualityUtils.isEqual(_schemaName, that._schemaName)
Copy link
Contributor

Choose a reason for hiding this comment

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

why removed _fieldSpecMap and _hasJSONColumn?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They are derived fields (similarly we don't include _dimensionNames etc.). Ideally we should define them as transient, but java ser/de still need to serialize these fields.

Copy link
Contributor

@xiangfu0 xiangfu0 left a comment

Choose a reason for hiding this comment

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

lgtm!

@xiangfu0
Copy link
Contributor

A high level question, will this handle the scenario that during schema evolution, a new column is created with default value and the CRC is still not change?

@61yao
Copy link
Contributor

61yao commented Mar 30, 2023

A high level question, will this handle the scenario that during schema evolution, a new column is created with default value and the CRC is still not change?

Piggy back another high level question: why adding a column needs to change the original segment :)

@Jackie-Jiang
Copy link
Contributor Author

@xiangfu0 @61yao If the change is applied in-place on the server side, we don't update (re-compute) the CRC even though the segment file is changed so that server won't re-download the segment from deep store

@Jackie-Jiang Jackie-Jiang merged commit 2c5adc8 into apache:master Mar 30, 2023
@Jackie-Jiang Jackie-Jiang deleted the metadata_deterministic_order branch March 30, 2023 17:36
@claudeyj
Copy link

Thank you for fixing this! Glad to know this PR got merged!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix release-notes Referenced by PRs that need attention when compiling the next release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants