Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sql: set the clean-up steps for pausable portal
This is part of the implementation of multiple active portals. To enable executing portals interleavingly, we need to persist certain resources for it, and delay their clean-up till we close the portal. Also, these resources don't need to be re-setup when we re-executing a portal. Thus we stores these cleanup steps in the `__Cleanup` function stacks in `portalPauseInfo`, and they are called when 1. sql txn is commited; 2. sql txn is rollbacked; 3. conn executor is closed. The cleanup functions should be called according to the original order of a normal portal. Since a portal's execution is via the `execPortal() -> execStmtInOpenState () -> dispatchToExecutionEngine() -> flow.Run()` function flow, we categorized the cleanup functions accordingly into 4 "layers": `exhaustPortal`, `execStmtCleanup` `dispatchToExecEngCleanup` and `flowCleanup`. The cleanup is always LIFO, i.e. following the `flowCleanup -> dispatchToExecEngCleanup -> execStmtCleanup -> exhaustPortal` order. Also, when there's error happens in each layer, cleanup the current and proceeding layers. e.g. if we encounter an error in `execStmtInOpenState()`, do `flowCleanup` and `dispatchToExecEngCleanup` (proceeding) and then `execStmtCleanup` (current), and return the error to `execPortal()`, where `exhaustPortal` will eventually be called. We also pass as reference the PreparedPortal to the planner in `execStmtInOpenState()`, so that the portal's flow can be set and reused. Release note: None
- Loading branch information