Fix gpexpand 'SyncPackages object has no attribute ret': enqueue OperationWorkerPool operations via items= - #1826
Conversation
OperationWorkerPool.__init__ passed its operations positionally to
WorkerPool.__init__, whose second positional parameter is should_stop
(items is the third). As a result operations were bound to should_stop
and items stayed None, so no operation was ever added to the work queue
and should_stop was set truthy. The worker only received the halt
command, ParallelOperation's operations never ran, Operation.run() never
assigned self.ret, and callers hit:
AttributeError: 'SyncPackages' object has no attribute 'ret'
This breaks gpexpand's first stage ("Syncing Apache Cloudberry
extensions"): the exception is squashed to a WARNING and, more
importantly, package/extension sync to new segment hosts silently never
runs.
This re-applies the fix from commit cd3c88f, which was reverted by
the REL_16_9 merge (0f4cf8d). Pass operations as the items keyword
so they are enqueued and should_stop stays False.
|
We have lost fix https://github.com/apache/cloudberry/pull/1716/changes while rebasing. Maybe we should just cherry-pick fix from PG14_ARCHIVE to main branch? |
+1. |
xinzweb
left a comment
There was a problem hiding this comment.
Verified this against current main rather than taking the description at face value:
WorkerPool.__init__(self, numWorkers=16, should_stop=False, items=None, ...)— confirmed by readinggpMgmt/bin/gppylib/commands/base.pydirectly;itemsis the 3rd positional param.OperationWorkerPool.__init__onmain(line 233) currently callssuper().__init__(numWorkers, operations)— positional, sooperationsbinds toshould_stopanditemsstaysNone. This exactly reproduces the reported bug: nothing gets enqueued,should_stopbecomes a truthy list, and the worker only ever receives the halt command.- The "this was already fixed once and silently reverted" claim checks out: commit
cd3c88f6e1e(2026-05-02) made this exact sameitems=operationschange, and it's absent frommainafter theMerge tag 'REL_16_9' into Cloudberrymerge (0f4cf8d5068, 2026-05-28) — confirmed both commits' SHAs, dates, and the merge's parents. - The fix (
items=operationsas a keyword arg) is correct against the actualWorkerPoolsignature.
Non-blocking note: there's no unit test covering OperationWorkerPool (no test_base.py under gpMgmt/bin/gppylib/test/unit), and this exact bug has now silently regressed once already via a merge with nothing to catch it. Might be worth a small follow-up test asserting the work queue actually gets populated — not blocking this fix, which is minimal and correct as-is.
CI is green across the board (build/RPM/DEB/rat-check/ic-*). LGTM.
Summary
Fixes #1825.
OperationWorkerPool.__init__passed itsoperationspositionally toWorkerPool.__init__:But
WorkerPool.__init__'s second positional parameter isshould_stop, and the work items are the third parameteritems:So
operationsbound toshould_stop(a truthy list) anditemsstayedNone. Consequently no operation was ever added to the work queue,should_stopwas set truthy, the worker only ever received the halt command, and the submitted operations never ran.Operation.run()therefore never assignedself.ret, and callers hit:This breaks the first stage of
gpexpand("Syncing Apache Cloudberry extensions"): the exception is squashed into aWARNING, and — more importantly — package/extension synchronization to new segment hosts silently never runs.Fix
Pass the operations as the
itemskeyword argument so they are enqueued andshould_stopstaysFalse:This re-applies commit
cd3c88f6e1e("Fix gppkg error: 'SyncPackages' object has no attribute 'ret'."), which was inadvertently reverted by theMerge tag 'REL_16_9' into Cloudberrymerge (0f4cf8d5068). On currentmain,grep -c "items=operations" gpMgmt/bin/gppylib/commands/base.pyreturns0.Testing
gpexpand -i <input> -vfirst stage no longer raises theAttributeError; theSyncPackagesoperation now actually executes (the-vlog shows the worker receiving the operation instead of only a halt command).See #1825 for the full root-cause analysis and the regression history.