Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Ruby] ChunkedArray raises an error in Ractor block #39488

Closed
KitaitiMakoto opened this issue Jan 6, 2024 · 1 comment · Fixed by #39490
Closed

[Ruby] ChunkedArray raises an error in Ractor block #39488

KitaitiMakoto opened this issue Jan 6, 2024 · 1 comment · Fixed by #39490

Comments

@KitaitiMakoto
Copy link

Describe the bug, including details regarding any error messages, version, and platform.

From red-data-tools/red_amber#289

When you access ChunkedArray's elements in Ractor block, it raises an error:

array = Arrow::Array.new([1, 2, 3])
chunked_array = Arrow::ChunkedArray.new([array])
Ractor.make_shareable(chunked_array)
ractor = Ractor.new {
  ca = Ractor.receive
  ca[0]
}
ractor.send(chunked_array)
ractor.take
#<Thread:0x0000000127354008 run> terminated with exception (report_on_exception is true):
~/src/github.com/apache/arrow/ruby/red-arrow/lib/arrow/chunked-array.rb:50:in `chunks': can't modify frozen Arrow::ChunkedArray: #<Arrow::ChunkedArray:0x1273546e8ptr=0x60000377f2a0 [ (FrozenError)
  [
    1,
    2,
    3
  ]
]>
        from ~/src/github.com/apache/arrow/ruby/red-arrow/lib/arrow/chunked-array.rb:80:in `[]'

I think most of

def iv
  @iv ||= init_instance_variable
end

pattern occur the same problem.

Component(s)

Ruby

kou added a commit to kou/arrow that referenced this issue Jan 7, 2024
kou added a commit to kou/arrow that referenced this issue Jan 7, 2024
kou added a commit to kou/arrow that referenced this issue Jan 7, 2024
@kou kou closed this as completed in #39490 Jan 7, 2024
kou added a commit that referenced this issue Jan 7, 2024
### Rationale for this change

We can't use `@ cache ||= build_cache` idiom in Ractor because Ractor requires that shared objects are immutable.

### What changes are included in this PR?

Compute caches before making ChunkedArray immutable.

### Are these changes tested?

Yes.

### Are there any user-facing changes?

Yes.
* Closes: #39488

Authored-by: Sutou Kouhei <kou@clear-code.com>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
@kou kou added this to the 15.0.0 milestone Jan 7, 2024
@KitaitiMakoto
Copy link
Author

Thanks!

clayburn pushed a commit to clayburn/arrow that referenced this issue Jan 23, 2024
…#39490)

### Rationale for this change

We can't use `@ cache ||= build_cache` idiom in Ractor because Ractor requires that shared objects are immutable.

### What changes are included in this PR?

Compute caches before making ChunkedArray immutable.

### Are these changes tested?

Yes.

### Are there any user-facing changes?

Yes.
* Closes: apache#39488

Authored-by: Sutou Kouhei <kou@clear-code.com>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
dgreiss pushed a commit to dgreiss/arrow that referenced this issue Feb 19, 2024
…#39490)

### Rationale for this change

We can't use `@ cache ||= build_cache` idiom in Ractor because Ractor requires that shared objects are immutable.

### What changes are included in this PR?

Compute caches before making ChunkedArray immutable.

### Are these changes tested?

Yes.

### Are there any user-facing changes?

Yes.
* Closes: apache#39488

Authored-by: Sutou Kouhei <kou@clear-code.com>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
zanmato1984 pushed a commit to zanmato1984/arrow that referenced this issue Feb 28, 2024
…#39490)

### Rationale for this change

We can't use `@ cache ||= build_cache` idiom in Ractor because Ractor requires that shared objects are immutable.

### What changes are included in this PR?

Compute caches before making ChunkedArray immutable.

### Are these changes tested?

Yes.

### Are there any user-facing changes?

Yes.
* Closes: apache#39488

Authored-by: Sutou Kouhei <kou@clear-code.com>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants