Skip to content

ice: Refactored multiple files processing to a separate function.#24

Merged
shyiko merged 5 commits intomasterfrom
2-ice-process-input-files-in-parallel
Apr 29, 2025
Merged

ice: Refactored multiple files processing to a separate function.#24
shyiko merged 5 commits intomasterfrom
2-ice-process-input-files-in-parallel

Conversation

@subkanthi
Copy link
Collaborator

@subkanthi subkanthi commented Apr 26, 2025

closes: #2

@subkanthi subkanthi linked an issue Apr 26, 2025 that may be closed by this pull request
@@ -0,0 +1,144 @@
package com.altinity.ice.internal.cmd;

public final class InsertOptions {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: s/class/record

if (retryLog != null) {
logger.error(
"{}: error (adding to retry list and continuing)", file, e);
retryLog.add(file);
Copy link
Collaborator

Choose a reason for hiding this comment

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

note to self: retryLog::add is thread-safe so this is fine

Thread.currentThread().interrupt();
throw new IOException("Interrupted while processing files", e);
} catch (ExecutionException e) {
if (retryLog == null) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

looks like queued up tasks are not canceled;
ExecutorService.close() executed when we exit

try (ExecutorService executor = Executors.newFixedThreadPool(numThreads)) {

on line 157 calls shutdown() (not shutdownNow()), i.e. it's going to block waiting for queued up tasks to complete even though tx won't be committed.

return new Builder();
}

public boolean skipDuplicates() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

all these methods are not needed now that InsertOptions is record (they are present by default)

Comment on lines +207 to +212
// Cancel any remaining tasks since we won't commit the transaction
if (finalOptions.noCommit() || !atLeastOneFileAppended) {
executor.shutdownNow();
} else {
executor.shutdown();
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// Cancel any remaining tasks since we won't commit the transaction
if (finalOptions.noCommit() || !atLeastOneFileAppended) {
executor.shutdownNow();
} else {
executor.shutdown();
}
executor.shutdownNow();

Copy link
Collaborator

Choose a reason for hiding this comment

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

we should probably awaitTermiantion too (as shutdown/shutdownNow don't do that)

@shyiko shyiko merged commit 2ee0368 into master Apr 29, 2025
1 check passed
shyiko added a commit that referenced this pull request May 12, 2025
ice insert: Fix race condition resulting from multiple threads using retryLog.add() without proper synchronization.
@shyiko shyiko deleted the 2-ice-process-input-files-in-parallel branch June 3, 2025 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ice: Process input files in parallel

2 participants