[CBRD-27302] Remove the duplicated trigger storage in db_root and _db_user - #7980
kangmin5505 wants to merge 4 commits into
Conversation
❌ TC Merge Gate — Merge BlockedOne or more TC PRs are still open. Please merge or close them before merging this PR. TC Repositories & Branches:
Steps to unblock:
|
|
@greptileai review |
🧪 TC Test Environment ReadyCircleCI Testing:
TC Repositories & Branches:
Next Steps:
|
There was a problem hiding this comment.
🟡 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_nameand shifts trigger lookup/listing to catalog queries. - Removes
db_root.triggersand_db_user.triggersusage, rebuilding user-trigger caching from_db_trigger. - Updates schema/view definitions to drop legacy
triggersattributes/columns and adjustsCNT_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.
|
CREATE가 무관한 dirty object의 오류를 트리거 이름 충돌로 오인하고 동시 RENAME이 잘못된 오류 계약을 노출할 수 있어 현재 상태로는 병합하기 안전하지 않습니다. Reviews (1) · Last reviewed commit: "Drop the _db_user.triggers list" |
|
/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.
e3fa210 to
ac14794
Compare
|
/run all |
ac14794 to
1e373c8
Compare
|
/run all |
|
/run shell |
06ae2f8 to
4611c4b
Compare
|
/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
|
/run all |
4611c4b to
dcbf5e4
Compare
|
/run shell |
http://jira.cubrid.org/browse/CBRD-27302
Purpose
_db_trigger외에db_root.triggers,_db_user.triggers에도 중복 저장하던 구조를 정리하고_db_trigger만 남긴다.db_rootinstance 에 X lock 을 잡아 커밋 전까지 새 접속을 막던 것을 없앤다.Implementation
_db_trigger에unique_nameprimary 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_OBJECTS10 → 7 (db_root.triggers,_db_user.triggers,db_user뷰의triggers컬럼).Remarks
CREATE TRIGGER u1.trg BEFORE COMMIT을 실행하거나ALTER TRIGGER … OWNER TO로 owner 를 바꾸면 갈린다.