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

Shared object error running Rails 7 with concurrent requests #2799

Open
headius opened this issue Nov 30, 2022 · 4 comments
Open

Shared object error running Rails 7 with concurrent requests #2799

headius opened this issue Nov 30, 2022 · 4 comments
Labels

Comments

@headius
Copy link
Contributor

headius commented Nov 30, 2022

I run into this occasionally attempting to run Rails 7 with Puma on TruffleRuby 22.3. It kills the server.

Caused by: java.lang.UnsupportedOperationException: Thread-safety bug: the object is already shared. This means another thread marked the object as shared concurrently.
	at org.truffleruby.language.objects.shared.ShareObjectNode.createSharedShape(ShareObjectNode.java:129)
	at org.truffleruby.language.objects.shared.ShareObjectNodeGen.executeAndSpecialize(ShareObjectNodeGen.java:99)
	at org.truffleruby.language.objects.shared.ShareObjectNodeGen.executeShare(ShareObjectNodeGen.java:69)
	at org.truffleruby.language.objects.shared.WriteBarrierNode.writeBarrierCached(WriteBarrierNode.java:69)
	at org.truffleruby.language.objects.shared.WriteBarrierNodeGen.executeWriteBarrier(WriteBarrierNodeGen.java:80)
	at org.truffleruby.core.array.library.ObjectArrayStore$ShareElements.shareElements(ObjectArrayStore.java:102)
	at org.truffleruby.core.array.library.ObjectArrayStoreGen$ArrayStoreLibraryExports$Cached.shareElements(ObjectArrayStoreGen.java:90)
	at org.truffleruby.core.array.library.ObjectArrayStore.makeShared(ObjectArrayStore.java:87)
	at org.truffleruby.core.array.library.ObjectArrayStoreGen$ArrayStoreLibraryExports$Cached.makeShared(ObjectArrayStoreGen.java:333)
	at org.truffleruby.language.objects.shared.ShareInternalFieldsNode.shareArray(ShareInternalFieldsNode.java:50)
	at org.truffleruby.language.objects.shared.ShareInternalFieldsNodeGen.executeShare(ShareInternalFieldsNodeGen.java:46)
	at org.truffleruby.language.objects.shared.ShareObjectNode.shareCached(ShareObjectNode.java:74)
	at org.truffleruby.language.objects.shared.ShareObjectNodeGen.executeShare(ShareObjectNodeGen.java:51)
	at org.truffleruby.language.objects.shared.WriteBarrierNode.writeBarrierCached(WriteBarrierNode.java:69)
	at org.truffleruby.language.objects.shared.WriteBarrierNodeGen.executeWriteBarrier(WriteBarrierNodeGen.java:80)
	at org.truffleruby.language.objects.shared.PropagateSharingNode.propagateShared(PropagateSharingNode.java:39)
	at org.truffleruby.language.objects.shared.PropagateSharingNodeGen.executePropagate(PropagateSharingNodeGen.java:39)
	at org.truffleruby.core.hash.library.PackedHashStoreLibrary$Set.setFirst(PackedHashStoreLibrary.java:180)
	at org.truffleruby.core.hash.library.PackedHashStoreLibraryGen$HashStoreLibraryExports$Cached.set(PackedHashStoreLibraryGen.java:102)
	at org.truffleruby.core.hash.library.HashStoreLibraryGen$CachedDispatch.set(HashStoreLibraryGen.java:999)
	at org.truffleruby.core.hash.library.EmptyHashStore.set(EmptyHashStore.java:49)
	at org.truffleruby.core.hash.library.EmptyHashStoreGen$HashStoreLibraryExports$Cached.set(EmptyHashStoreGen.java:86)
	at org.truffleruby.core.hash.HashNodes$SetIndexNode.set(HashNodes.java:239)
	at org.truffleruby.core.hash.HashNodesFactory$SetIndexNodeFactory$SetIndexNodeGen.execute(HashNodesFactory.java:981)
	at org.truffleruby.language.RubyCoreMethodRootNode.execute(RubyCoreMethodRootNode.java:48)

The app is a trivial generated "blog" scaffold app with Puma configured for 32 threads and siege doing 32 connections. If I drive the app with a few requests before starting benchmarking, it seems to fail less often.

@andrykonchin
Copy link
Member

Thank you for the report!

@eregon
Copy link
Member

eregon commented Dec 5, 2022

@headius Could you share the application?
That would make it a lot easier to reproduce, e.g., we don't have to guess which scaffolding commands were used, database, etc.
Besides it would be interesting to reproduce your benchmark numbers.

@headius
Copy link
Contributor Author

headius commented Dec 13, 2022

The application is the same setup as in #2804, but running on Linux on i7 in native mode.

@jedld
Copy link

jedld commented Jan 18, 2023

I am encountering the same error as well with 1000 concurrent request. Even used the docker image:

FROM ghcr.io/graalvm/truffleruby:debian-22.3
RUN apt-get update && apt-get --fix-broken install && apt-get update --fix-missing \
    && apt-get install -y wget \
        nginx \
        mariadb-client \
        vim \
        nano \
        procps \
        nodejs \
        make \
        git \
        build-essential \
        curl \
        libcurl4 \
        libcurl4-openssl-dev \
        default-libmysqlclient-dev
RUN mkdir -p  /usr/src/app/
WORKDIR /usr/src/app/
COPY . /usr/src/app/
RUN bundle
ENV RAILS_ENV=production
CMD rails s -p 8080 -b 0.0.0.0

below is the error encountered:

Puma starting in single mode...
* Puma version: 5.6.5 (truffleruby 22.3.0 - ruby 3.0.3) ("Birdie's Version")
*  Min threads: 75
*  Max threads: 75
*  Environment: production
*          PID: 1
* Listening on http://0.0.0.0:8080
Use Ctrl-C to stop
java.lang.RuntimeException: Ruby Thread id=93 from /opt/truffleruby-22.3.0/lib/gems/gems/puma-5.6.5/lib/puma/thread_pool.rb:104 terminated with internal error:
        at org.truffleruby.core.thread.ThreadManager.printInternalError(ThreadManager.java:305)
        at org.truffleruby.core.thread.ThreadManager.threadMain(ThreadManager.java:293)
        at org.truffleruby.core.thread.ThreadManager.lambda$initialize$2(ThreadManager.java:263)
        at [email protected]/java.lang.Thread.run(Thread.java:833)
        at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotThread.access$001(PolyglotThread.java:53)
        at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotThread$1.execute(PolyglotThread.java:100)
        at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotThread$ThreadSpawnRootNode.executeImpl(PolyglotThread.java:134)
        at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotThread$ThreadSpawnRootNode.execute(PolyglotThread.java:125)
        at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.executeRootNode(OptimizedCallTarget.java:709)
        at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.profiledPERoot(OptimizedCallTarget.java:632)
        at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callBoundary(OptimizedCallTarget.java:565)
        at com.oracle.svm.truffle.api.SubstrateOptimizedCallTarget.invokeCallBoundary(SubstrateOptimizedCallTarget.java:115)
        at com.oracle.svm.truffle.api.SubstrateOptimizedCallTargetInstalledCode.doInvoke(SubstrateOptimizedCallTargetInstalledCode.java:194)
        at com.oracle.svm.truffle.api.SubstrateOptimizedCallTarget.doInvoke(SubstrateOptimizedCallTarget.java:97)
        at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callIndirect(OptimizedCallTarget.java:477)
        at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.call(OptimizedCallTarget.java:458)
        at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotThread.run(PolyglotThread.java:96)
        at com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:775)
        at com.oracle.svm.core.posix.thread.PosixPlatformThreads.pthreadStartRoutine(PosixPlatformThreads.java:203)
Caused by: java.lang.UnsupportedOperationException: Thread-safety bug: the object is already shared. This means another thread marked the object as shared concurrently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants