stevenzwu commented on code in PR #7795:
URL: https://github.com/apache/iceberg/pull/7795#discussion_r1232470805
##########
flink/v1.15/flink/src/main/java/org/apache/iceberg/flink/FlinkCatalog.java:
##########
@@ -126,10 +126,13 @@ public FlinkCatalog(
@Override
public void open() throws CatalogException {
// Create the default database if it does not exist.
- try {
- createDatabase(getDefaultDatabase(), ImmutableMap.of(), true);
- } catch (DatabaseAlreadyExistException e) {
- // Ignore the exception if it's already exist.
+ String defaultDatabase = getDefaultDatabase();
+ if (!databaseExists(defaultDatabase)) {
+ try {
+ createDatabase(getDefaultDatabase(), ImmutableMap.of(), true);
+ } catch (DatabaseAlreadyExistException e) {
Review Comment:
this is also a little weird since we already did the `dataExists` check
earlier. I understand why this is needed to handle race condition when multiple
jobs can run this code path concurrently.
The first attempt of ignoring `ForbiddenException` was still not ideal to me
because it can mask real issue that default database wasn't created due to
permission issue.
I checked the 'HiveCatalog` and `GenericInMemoryCatalog` implementation from
Flink code. They don't try to create the default database in the `open` method.
Flink `HiveCatalog` just assert that default database exists. That behavior
seems reasonable to me.
cc @pvary
--
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]