Handle unparseable SupervisorSpec in metadata store (#14382)

Changes:
- Skip a supervisor spec entry which cannot be deserialised into a `SupervisorSpec` object.
- Log an error for the unparseable spec
This commit is contained in:
Rishabh Singh 2023-06-13 08:02:01 +05:30 committed by GitHub
parent 1c76ebad3b
commit 66c3cc1391
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 2 deletions

View File

@ -47,6 +47,7 @@ import org.skife.jdbi.v2.StatementContext;
import org.skife.jdbi.v2.tweak.HandleCallback;
import org.skife.jdbi.v2.tweak.ResultSetMapper;
import javax.annotation.Nullable;
import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;
@ -244,6 +245,7 @@ public class SQLMetadataSupervisorManager implements MetadataSupervisorManager
).map(
new ResultSetMapper<Pair<String, SupervisorSpec>>()
{
@Nullable
@Override
public Pair<String, SupervisorSpec> map(int index, ResultSet r, StatementContext ctx)
throws SQLException
@ -259,7 +261,13 @@ public class SQLMetadataSupervisorManager implements MetadataSupervisorManager
);
}
catch (IOException e) {
throw new RuntimeException(e);
String exceptionMessage = StringUtils.format(
"Could not map json payload to a SupervisorSpec for spec_id: [%s]."
+ " Delete the supervisor from the database and re-submit it to the overlord.",
r.getString("spec_id")
);
log.error(e, exceptionMessage);
return null;
}
}
}
@ -276,7 +284,9 @@ public class SQLMetadataSupervisorManager implements MetadataSupervisorManager
)
{
try {
retVal.put(stringObjectMap.lhs, stringObjectMap.rhs);
if (null != stringObjectMap) {
retVal.put(stringObjectMap.lhs, stringObjectMap.rhs);
}
return retVal;
}
catch (Exception e) {

View File

@ -275,6 +275,9 @@ public class SQLMetadataSupervisorManagerTest
specs = allSpecs.get(supervisor2);
Assert.assertEquals(1, specs.size());
Assert.assertNull(specs.get(0).getSpec());
Map<String, SupervisorSpec> latestSupervisorSpec = supervisorManager.getLatest();
Assert.assertEquals(1, latestSupervisorSpec.size());
}
@Test