Skip to content

[Branch-2.7][Cherry-pick] Fix skips compacted data for reader/consumer - #16301

Merged
Technoboy- merged 3 commits into
apache:branch-2.7from
Technoboy-:cherry-pick-12464
Jul 5, 2022
Merged

[Branch-2.7][Cherry-pick] Fix skips compacted data for reader/consumer#16301
Technoboy- merged 3 commits into
apache:branch-2.7from
Technoboy-:cherry-pick-12464

Conversation

@Technoboy-

Copy link
Copy Markdown
Contributor

Cherry-pick #12429, #12464

Motivation

The PR is fixing the compacted data lost during the data compaction.
We see a few events deletion but the compacted events obviously dropped a lot.

image

After investigating more details about the issue, only the first read operation reads the data from
the compacted ledger, since the second read operation, the broker start read data from the original
topic.

2021-10-19T23:09:30,021+0800 [broker-topic-workers-OrderedScheduler-7-0] INFO  org.apache.pulsar.compaction.CompactedTopicImpl - =====[public/default/persistent/c499d42c-75d7-48d1-9225-2e724c0e1d83] Read from compacted Ledger = cursor position: -1:-1, Horizon: 16:-1, isFirstRead: true
2021-10-19T23:09:30,049+0800 [broker-topic-workers-OrderedScheduler-7-0] INFO  org.apache.pulsar.compaction.CompactedTopicImpl - =====[public/default/persistent/c499d42c-75d7-48d1-9225-2e724c0e1d83] Read from original Ledger = cursor position: 16:0, Horizon: 16:-1, isFirstRead: false

#12429 only fixed the compactor skips data issue, but the normal reader/consumer also skips data while enabled read compacted data and read from the earliest position.

Modifications

The compaction task depends on the last snapshot and the incremental
entries to build the new snapshot. So for the compaction cursor, we
need to force seek the read position to ensure the compactor can read
the complete last snapshot because the compactor will read the data
before the compaction cursor mark delete position.

Verifying this change

New test added for checking the compacted data will not lost.

@Technoboy-
Technoboy- marked this pull request as ready for review June 30, 2022 09:39
@Technoboy- Technoboy- self-assigned this Jun 30, 2022
@Technoboy- Technoboy- closed this Jul 5, 2022
@Technoboy- Technoboy- reopened this Jul 5, 2022
codelipenghui and others added 2 commits July 5, 2022 11:34
The PR is fixing the compacted data lost during the data compaction.
We see a few events deletion but the compacted events obviously dropped a lot.

![image](https://user-images.githubusercontent.com/12592133/138008777-00eb7c0b-358e-4291-bfd4-f4b27cbedbf4.png)

After investigating more details about the issue, only the first read operation reads the data from
the compacted ledger, since the second read operation, the broker start read data from the original
topic.

```
2021-10-19T23:09:30,021+0800 [broker-topic-workers-OrderedScheduler-7-0] INFO  org.apache.pulsar.compaction.CompactedTopicImpl - =====[public/default/persistent/c499d42c-75d7-48d1-9225-2e724c0e1d83] Read from compacted Ledger = cursor position: -1:-1, Horizon: 16:-1, isFirstRead: true
2021-10-19T23:09:30,049+0800 [broker-topic-workers-OrderedScheduler-7-0] INFO  org.apache.pulsar.compaction.CompactedTopicImpl - =====[public/default/persistent/c499d42c-75d7-48d1-9225-2e724c0e1d83] Read from original Ledger = cursor position: 16:0, Horizon: 16:-1, isFirstRead: false
```

The compaction task depends on the last snapshot and the incremental
entries to build the new snapshot. So for the compaction cursor, we
need to force seek the read position to ensure the compactor can read
the complete last snapshot because the compactor will read the data
before the compaction cursor mark delete position.

New test added for checking the compacted data will not lost.
@Technoboy-
Technoboy- force-pushed the cherry-pick-12464 branch from c0d544c to cb791c8 Compare July 5, 2022 03:34
Comment thread pulsar-broker/src/test/java/org/apache/pulsar/compaction/CompactedTopicTest.java Outdated
@Technoboy-
Technoboy- merged commit 75e6a20 into apache:branch-2.7 Jul 5, 2022
@Technoboy-
Technoboy- deleted the cherry-pick-12464 branch August 10, 2022 05:52
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