veghlaci05 commented on a change in pull request #3126:
URL: https://github.com/apache/hive/pull/3126#discussion_r834262541
##########
File path: ql/src/java/org/apache/hadoop/hive/ql/txn/compactor/Worker.java
##########
@@ -627,18 +617,52 @@ public CompactorMR getMrCompactor() {
return new CompactorMR();
}
- private void markFailed(CompactionInfo ci, String errorMessage) {
- if (ci != null && StringUtils.isNotBlank(errorMessage)) {
- ci.errorMessage = errorMessage;
+ private void markWithState(CompactionInfo ci, Object error, CompactionState
state) {
+ if (ci == null) {
+ LOG.warn("Could not set compaction info state because it is null!");
+ throw new RuntimeException("Could not set compaction info state because
it is null!");
}
+ String defaultMessage = "Error during compaction. Compaction info: " + ci;
+ if (error != null) {
+ if (error instanceof Throwable) {
+ ci.errorMessage = ((Throwable)error).getMessage();
+ } else {
+ ci.errorMessage = error.toString();
+ }
+ }
+
if (msc == null) {
- LOG.warn("Metastore client was null. Could not mark failed: {}", ci);
- return;
+ LOG.warn("Metastore client was null. Could not set compaction info
state: {}", ci);
+ throw new RuntimeException("Metastore client was null. Could not set
compaction info state: " + ci);
}
+
try {
- msc.markFailed(CompactionInfo.compactionInfoToStruct(ci));
+ switch (state) {
+ case Failed: {
+ if (error instanceof Throwable) {
+ LOG.error(defaultMessage, (Throwable)error);
+ } else {
+ LOG.error(defaultMessage);
+ }
+ msc.markFailed(CompactionInfo.compactionInfoToStruct(ci));
+ break;
+ }
+ case Refused: {
+ if (error instanceof Throwable) {
+ LOG.error(defaultMessage, (Throwable)error);
+ } else {
+ LOG.warn(defaultMessage);
+ }
+ msc.markRefused(CompactionInfo.compactionInfoToStruct(ci));
+ break;
+ }
+ case Compacted: {
+ msc.markCompacted(CompactionInfo.compactionInfoToStruct(ci));
+ break;
+ }
+ }
} catch (Throwable t) {
- LOG.error("Caught an exception while trying to mark compaction {} as
failed: {}", ci, t);
+ LOG.error("Caught an exception while trying to set compaction {} state
{}", ci, t);
Review comment:
This is a nice catch, that would change the behavior. However in this
case inside the main
`catch (TException | IOException t)`
block a nested try..catch is required for the markWithState call. In that
catch block I think there's no other way than to log the error and move on.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]