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

Thread safety issue in connection.session_id #159

Closed
jacobat opened this issue Aug 3, 2018 · 1 comment
Closed

Thread safety issue in connection.session_id #159

jacobat opened this issue Aug 3, 2018 · 1 comment
Labels

Comments

@jacobat
Copy link

jacobat commented Aug 3, 2018

This code:

plsql.connection.instance_variable_set(:@session_id, nil)
4.times.map do |n|
  Thread.new do
    puts "Thread: #{n}\tSessionID: #{plsql.connection.session_id}"
    sleep 1
    puts "Thread: #{n}\tSessionID: #{plsql.connection.session_id}"
  end
end.map(&:join)

Returns:

Thread: 3       SessionID: 8893156
Thread: 2       SessionID: 8893159
Thread: 1       SessionID: 8893158
Thread: 0       SessionID: 8893157
Thread: 3       SessionID: 8893157
Thread: 2       SessionID: 8893157
Thread: 1       SessionID: 8893157
Thread: 0       SessionID: 8893157

Due to memoization here: https://github.com/rsim/ruby-plsql/blob/master/lib/plsql/connection.rb#L197

@jacobat jacobat changed the title Thread safety issue Thread safety issue in connection.session_id Aug 3, 2018
@stale
Copy link

stale bot commented Oct 2, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Oct 2, 2018
@stale stale bot closed this as completed Oct 9, 2018
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

1 participant