Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.apache.iotdb.it.framework.IoTDBTestRunner;
import org.apache.iotdb.itbase.category.ClusterIT;
import org.apache.iotdb.itbase.category.LocalStandaloneIT;
import org.apache.iotdb.itbase.exception.InconsistentDataException;

import org.apache.tsfile.enums.TSDataType;
import org.apache.tsfile.exception.write.WriteProcessException;
Expand Down Expand Up @@ -222,22 +223,29 @@ public void testWithNewModFileAndLoadAttributes()
tmpDir.getAbsolutePath(), databaseName));

boolean databaseFound = false;
out:
for (int i = 0; i < 10; i++) {
try (final ResultSet resultSet = statement.executeQuery("show databases")) {
while (resultSet.next()) {
final String currentDatabase = resultSet.getString(1);
if (databaseName.equalsIgnoreCase(currentDatabase)) {
databaseFound = true;
break out;
break;
}
}
} catch (InconsistentDataException ignored) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Catching InconsistentDataException and retrying is appropriate for this async load scenario. Optional: if all 10 retries fail, consider mentioning retry count in the final assertion message to simplify debugging. Not blocking.

// Async load propagates the new database metadata to different DataNodes at
// slightly different times, so "show databases" may be inconsistent transiently.
}

try {
Thread.sleep(1000);
} catch (InterruptedException e) {
break;
}
if (databaseFound) {
break;
}

try {
Thread.sleep(1000);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
break;
}
}
Assert.assertTrue(
Expand Down
Loading