Skip to content

KNOX-3253: Add advisory lock to the postgres table creation to avoid …#1157

Merged
smolnar82 merged 1 commit intoapache:masterfrom
hanicz:KNOX-3253
Feb 25, 2026
Merged

KNOX-3253: Add advisory lock to the postgres table creation to avoid …#1157
smolnar82 merged 1 commit intoapache:masterfrom
hanicz:KNOX-3253

Conversation

@hanicz
Copy link
Contributor

@hanicz hanicz commented Feb 25, 2026

…catalog race condition when multiple Knox instance start up simultaneously

KNOX-3253 - Improve Postgres DB table creation with locks

What changes were proposed in this pull request?

  • Adds advisory lock to the postgres table creation to avoid catalog race condition when multiple Knox instance start up simultaneously

How was this patch tested?

Manually tested with a local setup. I had postgres running in docker desktop and a local Knox instance. I created an advisory lock and created the table manually. Knox process was waiting on the lock. After unlocking it Knox proceeded with the knox_token_metadata table creation. Verified token creation on UI and DB as well.

    <property>
        <name>gateway.service.tokenstate.impl</name>
        <value>org.apache.knox.gateway.services.token.impl.JDBCTokenStateService</value>
    </property>
    <property>
        <name>gateway.database.type</name>
        <value>postgresql</value>
    </property>
    <property>
        <name>gateway.database.port</name>
        <value>5432</value>
    </property>
    <property>
        <name>gateway.database.host</name>
        <value>localhost</value>
    </property>
    <property>
        <name>gateway.database.name</name>
        <value>mydb</value>
    </property>

Integration Tests

N/A

UI changes

N/A

…catalog race condition when multiple Knox instance start up simultaneously
@hanicz hanicz requested a review from smolnar82 February 25, 2026 07:59
@github-actions
Copy link

Test Results

7 tests   7 ✅  1s ⏱️
1 suites  0 💤
1 files    0 ❌

Results for commit 9f6bd0c.

Copy link
Contributor

@smolnar82 smolnar82 left a comment

Choose a reason for hiding this comment

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

LGTM

@smolnar82 smolnar82 merged commit 5961ac2 into apache:master Feb 25, 2026
3 checks passed
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.

2 participants