Commit 73df8cd
committed
fix: query count discrepancy between MySQL and SQLite
Claude explanation: In `_create_side_effects_for_change_log`, `change_log.records.all()` has no `ORDER BY`. On SQLite, this returns records in insertion order (PK order) — which is root-first, since `publish_from_drafts` inserts the initial draft first, then its dependencies layer by layer. On MySQL/InnoDB, the query uses the `oel_plr_uniq_pl_publishable` unique index on (`publish_log`, `entity`) to service the `WHERE publish_log_id = ?` filter, which returns records in `entity_id` order — i.e. leaf-first, because `child_entity2` has a lower entity PK than `parent_of_two`, `grandparent`, etc.
The `processed_entity_ids` optimization on line 899–904 is order-sensitive: when you process leaf records first, `processed_entity_ids` isn't yet populated with their ancestors' IDs, so the while loop traverses all the way up the tree redundantly on each leaf1 parent fe1b594 commit 73df8cd
3 files changed
Lines changed: 3 additions & 17 deletions
File tree
- src/openedx_content/applets/publishing
- tests/openedx_content/applets
- containers
- sections
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
810 | 810 | | |
811 | 811 | | |
812 | 812 | | |
813 | | - | |
| 813 | + | |
814 | 814 | | |
815 | 815 | | |
816 | 816 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1273 | 1273 | | |
1274 | 1274 | | |
1275 | 1275 | | |
1276 | | - | |
1277 | | - | |
1278 | | - | |
1279 | | - | |
1280 | | - | |
| 1276 | + | |
1281 | 1277 | | |
1282 | 1278 | | |
1283 | 1279 | | |
| |||
1286 | 1282 | | |
1287 | 1283 | | |
1288 | 1284 | | |
1289 | | - | |
1290 | | - | |
1291 | | - | |
1292 | | - | |
1293 | | - | |
1294 | | - | |
1295 | | - | |
1296 | | - | |
1297 | | - | |
1298 | | - | |
1299 | 1285 | | |
1300 | 1286 | | |
1301 | 1287 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
157 | | - | |
| 157 | + | |
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
| |||
0 commit comments