Skip to content

dont commit while holding the lock on cleanup thread#1813

Draft
arthurpassos wants to merge 2 commits into
antalya-26.3from
export_partition_commit_no_lock
Draft

dont commit while holding the lock on cleanup thread#1813
arthurpassos wants to merge 2 commits into
antalya-26.3from
export_partition_commit_no_lock

Conversation

@arthurpassos
Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

  • Performance Improvement

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):

Don't commit while holding the export manifests locks. This avoid contention when the network / commit process is slow.

Documentation entry for user-facing changes

...

CI/CD Options

Exclude tests:

  • Fast test
  • Integration Tests
  • Stateless tests
  • Stateful tests
  • Performance tests
  • All with ASAN
  • All with TSAN
  • All with MSAN
  • All with UBSAN
  • All with Coverage
  • All with Aarch64
  • All Regression
  • Disable CI Cache

Regression jobs to run:

  • Fast suites (mostly <1h)
  • Aggregate Functions (2h)
  • Alter (1.5h)
  • Benchmark (30m)
  • ClickHouse Keeper (1h)
  • Iceberg (2h)
  • LDAP (1h)
  • Parquet (1.5h)
  • RBAC (1.5h)
  • SSL Server (1h)
  • S3 (2h)
  • S3 Export (2h)
  • Swarms (30m)
  • Tiered Storage (2h)

@arthurpassos
Copy link
Copy Markdown
Collaborator Author

@codex review

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 19, 2026

Workflow [PR], commit [1061618]

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8e4903309c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

removeStaleEntries(zk_children, entries_by_key);

LOG_INFO(storage.log, "ExportPartition Manifest Updating task: finished polling for new entries. Number of entries: {}", entries_by_key.size());
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep cleanup lock alive during deferred commit recovery

The cleanup_lock is created inside the inner scope and is destroyed when that scope ends, before deferred commit recovery starts; this allows another replica to acquire exports_cleanup_lock and run the same recovery path in parallel for the same task. In transient destination failures, each replica then calls handleCommitFailure and increments the shared commit_attempts, so max_retries can be exhausted much faster than intended and the task can flip to FAILED prematurely.

Useful? React with 👍 / 👎.

@arthurpassos
Copy link
Copy Markdown
Collaborator Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1061618543

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

/// A replica exported the last part but the commit never landed. Try to fix it.
try
{
ExportPartitionUtils::commit(work.metadata, work.destination_storage, zk, log_ptr, work.entry_path, work.context, storage);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Serialize deferred commit with cancellation

Running ExportPartitionUtils::commit after releasing export_merge_tree_partition_mutex introduces a race with StorageReplicatedMergeTree::killExportPartition: the kill path can now acquire the mutex and set /status to KILLED while this deferred commit is in flight, and commit then writes COMPLETED with an unconditional trySet(..., -1), effectively undoing a successful cancellation. Before this change, this cleanup-commit path was mutex-serialized with killExportPartition, so this regression can cause user-issued kill requests to be lost under concurrent recovery commits.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I think we can live with it for now

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.

1 participant