Skip to content

#135 Made DB name unique#137

Merged
ahsimb merged 3 commits into
mainfrom
bug/135-unique-db-name
Feb 11, 2026
Merged

#135 Made DB name unique#137
ahsimb merged 3 commits into
mainfrom
bug/135-unique-db-name

Conversation

@ahsimb
Copy link
Copy Markdown
Contributor

@ahsimb ahsimb commented Feb 11, 2026

closes #135

@ahsimb ahsimb self-assigned this Feb 11, 2026
@ahsimb ahsimb added the bug Unwanted / harmful behavior label Feb 11, 2026
now = datetime.now()
year_start = datetime(now.year, 1, 1)
minutes_elapsed = int((now - year_start).total_seconds() // 60)
random_suffix = time.time_ns() % 1048576
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

So, we would need more or less a nanosecond collision to generate the same name. And, the minutes since year start only can collide, if instances would run for more then a year.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, I come from assumption that nobody works around Xmas/New Year time. So, a DB left from the previous year is probably stuck and should be deleted. Overall, I call the names semi-unique, but it should be unique enough for practical purposes. Also, the minute resolution should be enough to see how long a DB is running.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I aimed to fit the changes into the same 10 characters that were previously occupied by the proper timestamp.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please note that this change will break some parts of our monitoring in GHA relying on the current specific timestamp format of the database names.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Where does the magic number 1048576 come from?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

2 ** 20 that cuts off a hex number 5 characters long.

Comment thread doc/changes/unreleased.md Outdated
now = datetime.now()
year_start = datetime(now.year, 1, 1)
minutes_elapsed = int((now - year_start).total_seconds() // 60)
random_suffix = time.time_ns() % 1048576
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please note that this change will break some parts of our monitoring in GHA relying on the current specific timestamp format of the database names.

Co-authored-by: Christoph Kuhnke <christoph.kuhnke@exasol.com>
now = datetime.now()
year_start = datetime(now.year, 1, 1)
minutes_elapsed = int((now - year_start).total_seconds() // 60)
random_suffix = time.time_ns() % 1048576
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Where does the magic number 1048576 come from?

@sonarqubecloud
Copy link
Copy Markdown

@ahsimb ahsimb merged commit 89e4c02 into main Feb 11, 2026
16 checks passed
@ahsimb ahsimb deleted the bug/135-unique-db-name branch February 11, 2026 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Unwanted / harmful behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generated database name must be unique

3 participants