Skip to content

Conversation

@HyukjinKwon
Copy link
Member

@HyukjinKwon HyukjinKwon commented Jan 7, 2026

@HyukjinKwon HyukjinKwon requested a review from kou as a code owner January 7, 2026 07:37
@HyukjinKwon HyukjinKwon marked this pull request as draft January 7, 2026 07:37
@HyukjinKwon
Copy link
Member Author

I will run the CI multiple times and see if this works..

@github-actions
Copy link

github-actions bot commented Jan 7, 2026

⚠️ GitHub issue #48752 has been automatically assigned in GitHub to PR creator.

@kou
Copy link
Member

kou commented Jan 7, 2026

Thanks for investing this but how did you confirm that Ractor.make_sharable(chunked_array) doesn't call chunked_array.freeze?

It seems that chunked_array.freeze is called:

require "arrow"
chunked_array = Arrow::ChunkedArray.new([Arrow::Int8Array.new([1])])
pp chunked_array.instance_variables # => []
Ractor.make_sharable(chunked_array)
pp chunked_array.instance_variables # => [:@chunks]

@HyukjinKwon
Copy link
Member Author

It works fine in my local (did you run it on Windows FWIW..?). I was just suspecting that this is specified to Windows just from my rough code reading and thought that's the only possibility but maybe I am wrong :-). I don't have any evidence for this fix so just wanted to trigger the builds few more times here.

@HyukjinKwon
Copy link
Member Author

I will update the PR description when I think it's ready to have a look 👍

@kou
Copy link
Member

kou commented Jan 7, 2026

Could you add these debug prints for checking the situation on CI?

diff --git a/ruby/red-arrow/test/test-ractor.rb b/ruby/red-arrow/test/test-ractor.rb
index 2aef74d01a..6a0c36dd7d 100644
--- a/ruby/red-arrow/test/test-ractor.rb
+++ b/ruby/red-arrow/test/test-ractor.rb
@@ -23,7 +23,9 @@ class RactorTest < Test::Unit::TestCase
     require_ruby(3, 1, 0)
     array = Arrow::Array.new([1, 2, 3])
     chunked_array = Arrow::ChunkedArray.new([array])
+    p chunked_array.instance_variables
     Ractor.make_shareable(chunked_array)
+    p chunked_array.instance_variables
     ractor = Ractor.new do
       recived_chunked_array = Ractor.receive
       recived_chunked_array.chunks

@HyukjinKwon
Copy link
Member Author

Sure!

@HyukjinKwon HyukjinKwon changed the title GH-48752: [Ruby] Fix ChunkedArray deadlock with Ractor.make_shareable on Windows GH-48752: [Ruby] Investigating ChunkedArray deadlock with Ractor.make_shareable on Windows Jan 7, 2026
@HyukjinKwon
Copy link
Member Author

hmmmmmmmm spending more time to understand the code with speclulation. Still trying to reproduce this in the builds at this PR

@HyukjinKwon HyukjinKwon force-pushed the GH-48752 branch 2 times, most recently from 778e0d8 to d522a64 Compare January 8, 2026 04:33
@kou
Copy link
Member

kou commented Jan 8, 2026

I also tried debug prints kou@076ba52 and https://github.com/kou/arrow/actions/runs/20804091327/job/59760921858#step:13:685 is a reproduced job:

11
D:/a/arrow/arrow/ruby/red-arrow/test/test-ractor.rb:28: warning: Ractor API is experimental and may change in future versions of Ruby.
22
33
44

It shows that any Ruby code in Ractor.new {...} isn't executed. So this may be a problem in Ruby itself.

Let's omit the test test for now:

diff --git a/ruby/red-arrow/test/test-ractor.rb b/ruby/red-arrow/test/test-ractor.rb
index 2aef74d01a..efd3cca1d4 100644
--- a/ruby/red-arrow/test/test-ractor.rb
+++ b/ruby/red-arrow/test/test-ractor.rb
@@ -20,6 +20,10 @@ class RactorTest < Test::Unit::TestCase
 
   ractor
   test("ChunkedArray") do
+    if Gem.win_platform?
+      omit("Ractor is unstable on Windows: " +
+           "https://github.com/apache/arrow/issues/48752")
+    end
     require_ruby(3, 1, 0)
     array = Arrow::Array.new([1, 2, 3])
     chunked_array = Arrow::ChunkedArray.new([array])

I'll report this to Ruby later.

@HyukjinKwon
Copy link
Member Author

okie dokie!

@HyukjinKwon
Copy link
Member Author

HyukjinKwon commented Jan 8, 2026

Actually @kou let me please dig a bit more. With:

      if frozen? && !instance_variable_defined?(:@chunks)
        return chunks_raw
      end

I wasn't able to reproduce this for 10 builds.

With the current fix

      if frozen? && !instance_variable_defined?(:@chunks)
        raise "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
      end

seems I am reproducing it all in 10 builds.

@HyukjinKwon
Copy link
Member Author

Although I don't have a clear evidence, I wonder if you feel comfortable with the change. It won't affect any other valid use cases from my understanding. If you feel unconfortable with that, let's just disable it on windows 🫡

@HyukjinKwon
Copy link
Member Author

Alright. Let me open a PR to skip this on Windows first, and I will take a look from my end separately!

@HyukjinKwon HyukjinKwon closed this Jan 8, 2026
@kou
Copy link
Member

kou commented Jan 8, 2026

I think that your assumption is not correct because our debug prints showed that @chunks is defined after Ractor.make_sharable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants