Skip to content

[CBRD-27302] Remove the duplicated trigger storage in db_root and _db_user - #7980

Draft
kangmin5505 wants to merge 4 commits into
CUBRID:developfrom
kangmin5505:cbrd-27302-trigger-storage
Draft

kangmin5505 wants to merge 4 commits into
CUBRID:developfrom
kangmin5505:cbrd-27302-trigger-storage

Conversation

@kangmin5505

@kangmin5505 kangmin5505 commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

http://jira.cubrid.org/browse/CBRD-27302

Purpose

  • 트리거 정보를 _db_trigger 외에 db_root.triggers, _db_user.triggers 에도 중복 저장하던 구조를 정리하고 _db_trigger 만 남긴다.
  • 트리거 DDL 이 db_root instance 에 X lock 을 잡아 커밋 전까지 새 접속을 막던 것을 없앤다.

Implementation

  • _db_triggerunique_name primary key 를 추가. 이름 중복은 check_semantics 가 걸러내고, 동시 생성 경쟁은 flush 시점에 key 가 거부한다.
  • db_root.triggers 제거. 이름 조회는 db_find_unique, 전체 목록(SHOW TRIGGERS, unloaddb)은 _db_trigger 질의로 대체.
    • db_get_all_objects 는 클래스에 S lock 을 잡아 동시 CREATE/DROP TRIGGER 와 막히므로 쓰지 않음.
  • _db_user.triggers 제거. user 트리거 캐시(tr_User_triggers)는 target_class IS NULL AND owner.name = CURRENT_USER 질의로 다시 만들고, tr_User_triggers_valid 게이트는 유지해 접속당 한 번 수준으로 질의.
    • CNT_CATCLS_OBJECTS 10 → 7 (db_root.triggers, _db_user.triggers, db_user 뷰의 triggers 컬럼).

Remarks

  • user 트리거(COMMIT/ROLLBACK 등)는 만든 세션이 아니라 owner 의 세션에서 발화. DBA 가 CREATE TRIGGER u1.trg BEFORE COMMIT 을 실행하거나 ALTER TRIGGER … OWNER TO 로 owner 를 바꾸면 갈린다.
  • 다른 세션이 만들거나 지우거나 owner 를 바꾼 user 트리거는 이 세션이 재접속하거나 자기 user 트리거 DDL 을 할 때 반영된다(세션별 캐시).

@kangmin5505 kangmin5505 self-assigned this Sep 18, 2026
@github-actions

github-actions Bot commented Sep 18, 2026

Copy link
Copy Markdown

❌ TC Merge Gate — Merge Blocked

One or more TC PRs are still open. Please merge or close them before merging this PR.

TC Repositories & Branches:

  • cubrid-testcases: TC PR tc/pr-7980 is open (draft) — must be merged or closed first
  • cubrid-testcases-private-ex: TC PR tc/pr-7980 is open (draft) — must be merged or closed first

Steps to unblock:

  1. Merge or close all TC PRs listed above.
  2. Re-run this check: Actions tab → TC Merge Gate → Re-run failed jobs

@kangmin5505

Copy link
Copy Markdown
Contributor Author

@greptileai review

@kangmin5505
kangmin5505 requested a lite review from Copilot September 18, 2026 06:33
@github-actions

Copy link
Copy Markdown

🧪 TC Test Environment Ready

CircleCI Testing:

  • CircleCI will automatically test using the branches below.

TC Repositories & Branches:

Next Steps:

  1. Wait for CircleCI tests to complete
  2. If CircleCI tests failed, please check the test results and fix the issues.
  3. When ready to merge this PR, please merge the TC PR first, then merge this PR.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The “all triggers” catalog query is currently unordered (risking nondeterministic dump/list output) and the new unconditional locator_all_flush() may impose unnecessary performance/behavioral impact.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

This PR refactors trigger metadata storage to eliminate duplicated trigger lists in db_root and _db_user, relying solely on the _db_trigger catalog, and aims to remove trigger DDL’s need to take an X lock on the db_root instance.

Changes:

  • Adds a primary key on _db_trigger.unique_name and shifts trigger lookup/listing to catalog queries.
  • Removes db_root.triggers and _db_user.triggers usage, rebuilding user-trigger caching from _db_trigger.
  • Updates schema/view definitions to drop legacy triggers attributes/columns and adjusts CNT_CATCLS_OBJECTS.
File summaries
File Description
src/object/trigger_manager.h Exposes new catalog query symbol and fetch helper API for trigger enumeration.
src/object/trigger_manager.c Replaces root/user trigger attribute access with _db_trigger queries; adds flush behavior to surface uniqueness early.
src/object/trigger_description.cpp Switches trigger dumping for unloaddb to use _db_trigger query results.
src/object/schema_system_catalog_install.cpp Adds PK on _db_trigger.unique_name; removes triggers column from user view definition.
src/object/schema_system_catalog_install_query_spec.cpp Removes triggers from db_user view query spec.
src/object/schema_system_catalog_constants.h Updates hard-coded system general-object-domain count from 10 to 7.
src/object/authenticate_context.cpp Removes legacy triggers attributes from db_root / _db_user class installation.
Review details
  • Files reviewed: 7/7 changed files
  • Comments generated: 3
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/object/trigger_manager.c
Comment thread src/object/trigger_manager.c Outdated
Comment thread src/object/trigger_manager.h
@greptile-apps

greptile-apps Bot commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Retrigger

CREATE가 무관한 dirty object의 오류를 트리거 이름 충돌로 오인하고 동시 RENAME이 잘못된 오류 계약을 노출할 수 있어 현재 상태로는 병합하기 안전하지 않습니다.

Reviews (1) · Last reviewed commit: "Drop the _db_user.triggers list"

Comment thread src/object/trigger_manager.c Outdated
@kangmin5505

Copy link
Copy Markdown
Contributor Author

/run all

Uniqueness was enforced only by the db_root.triggers registry, so a row
that never reached it — as in CBRD-27275 — left a second trigger of the
same name.
@kangmin5505
kangmin5505 force-pushed the cbrd-27302-trigger-storage branch from e3fa210 to ac14794 Compare September 18, 2026 10:22
@kangmin5505

Copy link
Copy Markdown
Contributor Author

/run all

@kangmin5505
kangmin5505 force-pushed the cbrd-27302-trigger-storage branch from ac14794 to 1e373c8 Compare September 20, 2026 13:25
@kangmin5505

Copy link
Copy Markdown
Contributor Author

/run all

@kangmin5505

Copy link
Copy Markdown
Contributor Author

/run shell

@kangmin5505
kangmin5505 force-pushed the cbrd-27302-trigger-storage branch from 06ae2f8 to 4611c4b Compare September 21, 2026 08:52
@kangmin5505

Copy link
Copy Markdown
Contributor Author

/run all

Name lookup, the duplicate-name check and the full trigger list are now
queries on _db_trigger, which the unique_name key makes cheap. Keeping
the registry cost an instance lock on db_root, and every new connection
reads that instance, so uncommitted trigger DDL blocked unrelated logins.
The user trigger cache is rebuilt from _db_trigger instead, and the
tr_User_triggers_valid gate stays, so the query runs about once per
connection rather than on every commit. CURRENT_USER stands in for the
user name, which may contain a quote.

A user trigger now fires for its owner rather than its creator; the two
differ only when a DBA creates one for another user.
…er-storage

# Conflicts:
#	src/object/schema_system_catalog_constants.h
@kangmin5505

Copy link
Copy Markdown
Contributor Author

/run all

@kangmin5505
kangmin5505 force-pushed the cbrd-27302-trigger-storage branch from 4611c4b to dcbf5e4 Compare September 21, 2026 09:12
@kangmin5505

Copy link
Copy Markdown
Contributor Author

/run shell

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