Skip to content

Put the create_new_file_on_insert sequence number into the file name, not a directory - #129630

Merged
alexey-milovidov merged 2 commits into
masterfrom
fix-create-new-file-on-insert-dot-in-directory
Nov 6, 2026
Merged

alexey-milovidov merged 2 commits into
masterfrom
fix-create-new-file-on-insert-dot-in-directory

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

With s3_create_new_file_on_insert (and azure_create_new_file_on_insert, hdfs_create_new_file_on_insert), when the target key already exists, checkAndGetNewFileOnInsertIfNeeded inserted the sequence number before the first dot of the whole key, using key.find_first_of('.'). When a directory name contains a dot, the number went into the directory:

INSERT INTO FUNCTION s3('http://host/bucket/team.v1/data.tsv', 'TSV', 'x UInt32')
SETTINGS s3_create_new_file_on_insert = 1 VALUES (1);   -- run twice

The second insert wrote team.1.v1/data.tsv, a new "directory", so s3('http://host/bucket/team.v1/*') did not see it. The same happens with PARTITION BY when the partition id puts a dot into a directory name.

Now the number goes before the first dot of the last path component, so the second insert writes team.v1/data.1.tsv. Keys without a dot in a directory name are named the same as before.

This changes the names of new files only for keys that have a dot in a directory name. That is intended: the old names put files outside the directory they were written to.

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

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

With s3_create_new_file_on_insert, azure_create_new_file_on_insert or hdfs_create_new_file_on_insert, the sequence number of a new file is now inserted before the first dot of the file name, not before the first dot of the whole path. Previously, if a directory name contained a dot (e.g. team.v1/data.tsv), the new file was written into a different directory (team.1.v1/data.tsv).

🤖 Generated with Claude Code


Workflow [PR]
Sync PR [sync-upstream/pr/129630]

Version info

  • Merged into: 26.11.1.1575-master (included in 26.11 and later)

…e, not a directory

With `s3_create_new_file_on_insert` (and the `azure_`/`hdfs_` analogues), when the
key already exists, the new key got the sequence number before the first dot of the
whole key. If a directory name contained a dot (e.g. `team.v1/data.tsv`, or a
`PARTITION BY` path like `part.{_partition_id}/data.tsv`), the file was written into
a new "directory" (`team.1.v1/data.tsv`) and was not visible to `team.v1/*`.

Now the number is inserted before the first dot of the last path component:
`team.v1/data.1.tsv`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [1d6d7bc]

Summary: ✅


AI Review

Summary

PR #129630 fixes s3_create_new_file_on_insert and its Azure/HDFS counterparts by inserting sequence numbers into the file name while preserving dotted directory paths. The regression test covers repeated inserts, extensionless files, and partitioned writes. No actionable findings at commit 1d6d7bc21b33544e8cd8755f2dbce64f12a929ee. Review was based on source and test inspection; tests were not run locally.

Final Verdict

Status: ✅ Approve.

@clickhouse-gh clickhouse-gh Bot added pr-bugfix Pull request with bugfix, not backported by default comp-object-storage Object storage connectivity (S3/GCS/Azure) including credentials, retries, multipart, etc. labels Nov 5, 2026
@clickhouse-gh

clickhouse-gh Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 1d6d7bc21 with master 748cd0e55 (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Compile time of recompiled translation units

7 translation units recompiled, 11 s compile time in total, 7 of them have a recent master baseline.

Job report

@alexey-milovidov
alexey-milovidov marked this pull request as ready for review November 6, 2026 19:58

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Trivial, LGTM.

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Nov 6, 2026
Merged via the queue into master with commit 1f2f88e Nov 6, 2026
187 checks passed
@alexey-milovidov
alexey-milovidov deleted the fix-create-new-file-on-insert-dot-in-directory branch November 6, 2026 23:46
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-object-storage Object storage connectivity (S3/GCS/Azure) including credentials, retries, multipart, etc. pr-bugfix Pull request with bugfix, not backported by default pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants