Commit 3b6cbfb
committed
fix(pg): prevent debug assertion crash on cloudsync_init error path
In cloudsync_init_internal, when cloudsync_init_table returns an error
(e.g. unsupported DWS/AWS algorithm), the error path called
database_rollback_savepoint() which internally pushes a new active
snapshot via database_refresh_snapshot(). The subsequent ereport(ERROR)
longjmps through PG_CATCH → SPI_finish → PL/pgSQL exception handler,
where EnsurePortalSnapshotExists() finds portal->portalSnapshot still
set, triggering Assert(portal->portalSnapshot == NULL) in debug builds.
Replace database_rollback_savepoint() with a direct call to
RollbackAndReleaseCurrentSubTransaction(), skipping the snapshot refresh.
Since we're about to propagate an error, PostgreSQL's error recovery
handles snapshot cleanup automatically.
Other callers of database_rollback_savepoint are safe because they either
run on SQLite, return normally instead of raising ereport(ERROR), or
disconnect SPI before the rollback.1 parent 7a3d1d5 commit 3b6cbfb
1 file changed
+11
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
305 | 305 | | |
306 | 306 | | |
307 | 307 | | |
308 | | - | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
309 | 316 | | |
310 | 317 | | |
311 | | - | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
312 | 321 | | |
313 | 322 | | |
314 | 323 | | |
| |||
0 commit comments