chenshzh opened a new pull request, #6121:
URL: https://github.com/apache/hudi/pull/6121
Currently CompactionCommitSink commit or rollback logics doesn't take the
writestatus error under consideration (only consider null writestatus), which
actually will cause data loss when compacting the delta commit log files into
the new versioned data files.
eg. org.apache.hudi.io.HoodieMergeHandle#writeRecord will lead to data loss
from log files due to Exceptions.
```java
protected boolean writeRecord(HoodieRecord<T> hoodieRecord,
Option<IndexedRecord> indexedRecord, boolean isDelete) {
Option recordMetadata = hoodieRecord.getData().getMetadata();
if (!partitionPath.equals(hoodieRecord.getPartitionPath())) {
HoodieUpsertException failureEx = new
HoodieUpsertException("mismatched partition path, record partition: "
+ hoodieRecord.getPartitionPath() + " but trying to insert into
partition: " + partitionPath);
writeStatus.markFailure(hoodieRecord, failureEx, recordMetadata);
return false;
}
try {
if (indexedRecord.isPresent() && !isDelete) {
writeToFile(hoodieRecord.getKey(), (GenericRecord)
indexedRecord.get(), preserveMetadata && useWriterSchemaForCompaction);
recordsWritten++;
} else {
recordsDeleted++;
}
writeStatus.markSuccess(hoodieRecord, recordMetadata);
// deflate record payload after recording success. This will help
users access payload as a
// part of marking
// record successful.
hoodieRecord.deflate();
return true;
} catch (Exception e) {
LOG.error("Error writing record " + hoodieRecord, e);
writeStatus.markFailure(hoodieRecord, e, recordMetadata);
}
return false;
}
```
And it's known that StreamWriteOperatorCoordinator has related commit or
rollback handle process.
So this pr will:
a) Also add writestatus error as rollback reason for CompactionCommitSink
compaction rollback to avoid data loss
b) Unify the handle procedure for write commit policy with its
implementions, as described in org.apache.hudi.commit.policy.WriteCommitPolicy,
which is consolidated with that of StreamWriteOperatorCoordinator.
c) All control whether data quality or ingestion stability should be in high
priority through FlinkOptions#IGNORE_FAILED.
And, we suggest that FlinkOptions#IGNORE_FAILED be in true by default to
avoid data loss.
d) Optimize and fix some tiny bugs for log traces when commiting on error or
rolling back.
## *Tips*
- *Thank you very much for contributing to Apache Hudi.*
- *Please review https://hudi.apache.org/contribute/how-to-contribute before
opening a pull request.*
## What is the purpose of the pull request
*(For example: This pull request adds quick-start document.)*
## Brief change log
*(for example:)*
- *Modify AnnotationLocation checkstyle rule in checkstyle.xml*
## Verify this pull request
*(Please pick either of the following options)*
This pull request is a trivial rework / code cleanup without any test
coverage.
*(or)*
This pull request is already covered by existing tests, such as *(please
describe tests)*.
(or)
This change added tests and can be verified as follows:
*(example:)*
- *Added integration tests for end-to-end.*
- *Added HoodieClientWriteTest to verify the change.*
- *Manually verified the change by running a job locally.*
## Committer checklist
- [ ] Has a corresponding JIRA in PR title & commit
- [ ] Commit message is descriptive of the change
- [ ] CI is green
- [ ] Necessary doc changes done or have another open PR
- [ ] For large changes, please consider breaking it into sub-tasks under
an umbrella JIRA.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]