Skip to content

Close abandoned CSV readers; bump clojask-io to 1.0.7 - #85

Merged
clojure-finance merged 1 commit into
2.x.xfrom
clojask-io-close
Sep 25, 2026
Merged

clojure-finance merged 1 commit into
2.x.xfrom
clojask-io-close

Conversation

@buehlmaier

Copy link
Copy Markdown
Collaborator

Batch 4 of the agreed plan, clojask side. clojask-io 1.0.7 (released today) closes its reader when :data is fully consumed and returns a :close function for consumers that stop early. This PR bumps the dep and uses :close at every site that abandons a reader partway — which turned out to be most of them:

  • dataframe construction opened three to four readers per call (:clojask-io probe, header, stat, output fn) and abandoned each after at most one line. It now realizes the io result once, reuses it for the header row, :path, :size and :output, and closes it.
  • The stored read function gains a second arity returning {:data ... :close ...} so partial consumers can reach the reader; the 0-arity behavior is unchanged (Onyx input plugin, full computes).
  • preview fetches through the new arity and closes in a finally. That covers print-df, the public preview, and every errorPredetect — including when the previewed pipeline throws, which is exactly the errorPredetect failure path.

Readers abandoned when an Onyx job dies mid-compute still linger until GC (nothing holds the :close handle across the job); full computes now close on exhaustion via 1.0.7. The bind extensions still open stat-only readers without closing them — left as is, they build their own io maps and are out of scope here.

Test written first and seen failing (5 readers opened, 0 closed): wraps clojask-io.input/read-file to count opened vs closed readers across construction, preview, and a failing errorPredetect. Suite: 50 tests / 184 assertions, green locally on JDK 25.

No version bump; rides with #83/#84 in a later 2.0.6.

clojask-io 1.0.7 closes its reader when :data is fully consumed and
returns a :close function for consumers that stop early. Use both:

- dataframe construction opened three to four readers per call (header
  probe, stat, output fn) and abandoned them all after at most one line.
  It now realizes the io result once, reuses it for the header, size and
  output function, and closes it.
- The stored read function gains a second arity returning
  {:data ... :close ...} so partial consumers can reach the reader.
- preview fetches through that arity and closes in a finally, which also
  covers every errorPredetect and print-df, including when a preview
  throws (the errorPredetect failure path).

Readers abandoned when an Onyx job dies mid-compute still wait for GC;
full computes close on exhaustion via 1.0.7.

Test written first and seen failing (5 readers opened, 0 closed): counts
opened vs closed readers across construction, preview, and a failing
errorPredetect.
@clojure-finance
clojure-finance merged commit e702ebf into 2.x.x Sep 25, 2026
3 checks passed
@buehlmaier
buehlmaier deleted the clojask-io-close branch September 25, 2026 02:58
@buehlmaier buehlmaier mentioned this pull request Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants