Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync to 1.1: restore the switched account id when mo_table_size and mo_table_rows. #14741

Merged

Conversation

gouhongshen
Copy link
Contributor

@gouhongshen gouhongshen commented Feb 29, 2024

What type of PR is this?

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

Which issue(s) this PR fixes:

issue ##13151

What this PR does / why we need it:

see ##14740 for details.

@matrix-meow matrix-meow added the size/M Denotes a PR that changes [100,499] lines label Feb 29, 2024
@mergify mergify bot requested a review from sukki37 February 29, 2024 09:23
@mergify mergify bot added the kind/bug Something isn't working label Feb 29, 2024
@sukki37 sukki37 merged commit 5b2c4b7 into matrixorigin:1.1-dev Mar 4, 2024
14 of 16 checks passed
mergify bot pushed a commit that referenced this pull request Mar 5, 2024
…ws`. (#14740)

consider this situation:
```
select dbName, count(*) as tblCnt, sum(tblSize) / (1024 * 1024.0) as db_size_in_mb
from (
select reldatabase as dbName, mo_table_size(reldatabase, relname) as tblSize
from
mo_catalog.mo_tables  left join mo_catalog.mo_database
on reldatabase_id = dat_id
where relkind in
('r', 'cluster', 'e') and
mo_catalog.mo_tables.account_id = ( select current_account_id() as cur_acc_id)
)
group by dbName
order by db_size_in_mb;
```

if an SQL tries to gather all tables' sizes in one query, this will traverse all tables, including the cluster table, belongs this account.

but if these tables in `tbls` has orders: xxx, cluster table, xxx, xxx, xxx, the account id stored in proc.Ctx will be changed to system account ID when processing that cluster table, causing the last three tables to not be found when calling the `engine.Database()`. so should be first to switch back to the right account ID when new round.


cherry-pick to 1.1: #14741

Approved by: @XuPeng-SH, @m-schen
gouhongshen added a commit to gouhongshen/matrixone that referenced this pull request Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working size/M Denotes a PR that changes [100,499] lines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants