Skip to content

Agent/catalog incremental discovery - #26616

Merged
XuPeng-SH merged 98 commits into
matrixorigin:mainfrom
jiangxinmeng1:agent/catalog-incremental-discovery
Aug 26, 2026
Merged

XuPeng-SH merged 98 commits into
matrixorigin:mainfrom
jiangxinmeng1:agent/catalog-incremental-discovery

Conversation

@jiangxinmeng1

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #26615

What this PR does / why we need it:

Agent/catalog incremental discovery

…mental-discovery

# Conflicts:
#	pkg/sql/plan/function/func_binary.go
#	pkg/sql/plan/function/list_builtIn.go
#	pkg/sql/plan/query_builder.go
#	test/distributed/cases/function/func_datetime_maketime.result
#	test/distributed/cases/function/func_datetime_maketime.test
@jiangxinmeng1
jiangxinmeng1 requested a review from a user August 3, 2026 06:41
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@XuPeng-SH XuPeng-SH 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.

Blocking security issue: table_changes bypasses the source table's SELECT privilege. The planner resolves the source only to derive the result schema, then emits a Node_FUNCTION_SCAN without a privilege-bearing TABLE_SCAN/source object reference. extractPrivilegeTipsFromPlan therefore sees no table, len(arr) == 0, and authentication allows the statement. The executor opens the relation directly.

I reproduced this on exact head b9b34016c79b with an authenticated embedded cluster:

  1. Create secret(id primary key, payload) and insert classified.
  2. Create a user whose role has only CONNECT, no SELECT on the database/table.
  3. select payload from db.secret is correctly rejected with do not have privilege.
  4. The same user successfully executes select payload from table_changes('db', 'secret', after, until) and receives classified.

Please make table_changes contribute the same source-table SELECT privilege requirement as a normal scan (including the existing cluster/catalog access rules), and add deny/allow black-box privilege tests. Tenant filtering is not a substitute for authorization within a tenant.

@LeftHandCold LeftHandCold left a comment

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.

Reviewed repository matrixorigin/matrixone, PR #26616 at exact head 0d694dca45b09bff252639b10a2644dcb78bd233 against base/merge-base 94528dcb63d55921b936cda611ea61eb1862ea79.

Requesting changes for one remaining merge blocker:

[P1] Initialize logical seqnums on the real table_changes path before normalizing in-memory rows

The new argument at pkg/vm/engine/disttae/change_handle.go:401 is normally still nil. txnTable.seqnums is populated only by ensureSeqnumsAndTypesExpectRowid, whose production callers are the object-compaction and merge paths (txn.go:2356 and txn_table.go:3311). The normal tableChangesState path does CopyTableDef and then CollectChanges (table_changes.go:162,202), neither of which initializes that cache. The constructor therefore copies nil at logtailreplay/change_handle.go:3008, and fillInInsertBatch takes its legacy fallback at lines 3984-3990, preserving physical rather than logical order.

For CREATE TABLE t(id PK, payload); ALTER TABLE t ADD COLUMN added FIRST, the intended logical seqnums are [2,0,1], but a targeted regression matching the pre-CollectChanges table_changes sequence gets tbl.seqnums == nil. The new helper test passes only because it supplies [2,0,1] directly, so it does not exercise this broken connection. In production the prior failure remains: an in-memory physical batch [id,payload,added] is exposed as if logical and the logical primaryIdx can select payload, preventing same-PK insert/delete cancellation and mislabeling output columns.

Please derive/capture the current logical seqnums from the table definition before building the deferred range handler (or otherwise guarantee synchronized initialization), and add a handler/public-path no-flush regression for ADD FIRST/AFTER and a dropped-column hole, including same-PK insert-delete and spill. The previous update-delete test-construction blocker is fixed; both newly modified focused tests pass locally.

@LeftHandCold LeftHandCold left a comment

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.

Re-reviewed exact head 51b9b1f. The previous P1 is fixed: CollectChanges now initializes the current logical-to-physical seqnum mapping before constructing the range handle, and the visible-state snapshot transition initializes and captures the snapshot relation's own mapping together with its primary indexes. This closes the production handoff that the earlier helper-only test missed. The mapping is copied into the deferred handle, and the existing focused tests cover reordered physical columns and logical-PK net effects. I found no remaining code blocker in this delta. Approving; the remaining CI jobs can complete independently.

@mergify

mergify Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-08-26 08:44 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-08-26 09:15 UTC · at e70f0d6c24fb9baa7a2365ec36a03e14faa4e2e4

This pull request spent 30 minutes 33 seconds in the queue, with no time running CI.

Waiting for
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
    • check-success = Matrixone CI / SCA Test on Linux/arm64
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
    • check-success = Matrixone Utils CI / Coverage
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-skipped = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-success = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-success = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
All conditions
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
    • check-success = Matrixone CI / SCA Test on Linux/arm64
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
    • check-success = Matrixone Utils CI / Coverage
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-skipped = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-success = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-success = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection]

Reason

Pull request #26616 has been dequeued

Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.

The author needs to enable "Allow edits from maintainers" on this pull request.

Failing checks:

Hint

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.
If you do update this pull request, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/feature size/XXL Denotes a PR that changes 2000+ lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants