Skip to content

Commit 7e8a391

Browse files
author
Grok Compression
committed
Fix deadlock in synchronous selective fetch: unblock row throttle in wait()
wait(nullptr) only called setLastClearedTileY(INT16_MAX) when doTileBatching() was true (requires asynchronous mode). In synchronous CLI mode, the row-based fetch throttle in fetchByTileSelective blocked after filling maxRowsAhead_ rows because lastCleared never advanced. This caused decompress of large images (e.g. 121 tiles) to hang. Fix: always unblock the throttle when tileCompletion_ is set, regardless of whether tile batching is active. Only call scheduleTileBatch() when batching is actually in use.
1 parent 9559972 commit 7e8a391

2 files changed

Lines changed: 51 additions & 2 deletions

File tree

.vscode/launch.json

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,6 +1345,52 @@
13451345
],
13461346
"MIMode": "gdb",
13471347
"miDebuggerPath": "/usr/bin/gdb"
1348+
},
1349+
{
1350+
"name": "TCI Selective Fetch MINIO",
1351+
"type": "cppdbg",
1352+
"request": "launch",
1353+
"program": "${workspaceFolder}/build/bin/grk_decompress",
1354+
"args": [
1355+
"-i",
1356+
"/vsis3/grok/T32TQM_20241115T100159_TCI_10m.jp2",
1357+
"-o",
1358+
"$HOME/temp/tci_selective.tif",
1359+
// "-r",
1360+
// "2"
1361+
],
1362+
"cwd": "${workspaceFolder}",
1363+
"environment": [
1364+
{ "name": "GRK_DEBUG", "value": "4" },
1365+
{ "name": "AWS_ACCESS_KEY_ID", "value": "minioadmin" },
1366+
{ "name": "AWS_SECRET_ACCESS_KEY", "value": "minioadmin" },
1367+
{ "name": "AWS_S3_ENDPOINT", "value": "localhost:9000" },
1368+
{ "name": "AWS_VIRTUAL_HOSTING", "value": "FALSE" },
1369+
{ "name": "AWS_HTTPS", "value": "YES" },
1370+
{ "name": "GRK_CURL_ALLOW_INSECURE", "value": "YES" }
1371+
],
1372+
"MIMode": "gdb",
1373+
"miDebuggerPath": "/usr/bin/gdb"
1374+
},
1375+
{
1376+
"name": "TCI Selective Fetch",
1377+
"type": "cppdbg",
1378+
"request": "launch",
1379+
"program": "${workspaceFolder}/build/bin/grk_decompress",
1380+
"args": [
1381+
"-i",
1382+
"~/temp/T32TQM_20241115T100159_TCI_10m.jp2",
1383+
"-o",
1384+
"$HOME/temp/tci_selective.tif",
1385+
"-r",
1386+
"2"
1387+
],
1388+
"cwd": "${workspaceFolder}",
1389+
"environment": [
1390+
{ "name": "GRK_DEBUG", "value": "3" },
1391+
],
1392+
"MIMode": "gdb",
1393+
"miDebuggerPath": "/usr/bin/gdb"
13481394
}
13491395
],
13501396
"inputs": [

src/lib/core/codestream/decompress/CodeStreamDecompress.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1449,12 +1449,15 @@ void CodeStreamDecompress::wait(grk_wait_swath* swath)
14491449
// the back-pressure logic in scheduleTileBatch() prevents scheduling queued tiles
14501450
// because lastCleared never advances (no swath consumer). Force-schedule all
14511451
// remaining tiles so the worker thread can exit.
1452-
if(tileCompletion_ && doTileBatching())
1452+
// Also unblock the fetch throttle for selective fetch (fetchByTileSelective),
1453+
// which uses the row-based throttle even in synchronous mode.
1454+
if(tileCompletion_)
14531455
{
14541456
// Remove the scheduling limit so scheduleTileBatch can drain
14551457
batchTileScheduledRows_ = 0;
14561458
tileCompletion_->setLastClearedTileY(INT16_MAX);
1457-
scheduleTileBatch();
1459+
if(doTileBatching())
1460+
scheduleTileBatch();
14581461
}
14591462

14601463
// 2b. wait for sequential parse

0 commit comments

Comments
 (0)