Skip to content

Commit

Permalink
Review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
mrhardikjoshi committed Dec 24, 2023
1 parent a958dab commit ea53581
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 25 deletions.
2 changes: 1 addition & 1 deletion lib/active_graph/transactions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def read_transaction(**config, &block)
alias transaction write_transaction

def lock_node(node)
node.as(:n).query.remove('n._AGLOCK_').exec if tx&.open? || explicit_session&.open?
node.as(:n).query.remove('n._AGLOCK_').exec if tx&.open?
end

private
Expand Down
24 changes: 0 additions & 24 deletions spec/e2e/relationship/persistence/query_factory_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,30 +103,6 @@ def self.count
expect(from_node.reload.to_classes).to be_empty
end

context 'concurrent update' do
before do
allow_any_instance_of(ActiveGraph::Node::Query::QueryProxy).to receive(:replace_with).and_wrap_original do |original, *args|
$concurrency_queue << 'ready'
Thread.stop
original.call(*args)
end
end
after { $concurrency_queue = nil }
let!(:from_node) { FromClass.create(name: 'foo') }
let!(:to_node) { ToClass.create(name: 'bar') }

it 'does not create duplicate has_one relationship' do
count = 100
$concurrency_queue = Thread::Queue.new
threads = count.times.map { Thread.new { to_node.update(from_class: from_node) } }
sleep(0.1) until $concurrency_queue.size == count
$concurrency_queue.clear
threads.each(&:run)
threads.each(&:join)
expect(ActiveGraph::Base.query("MATCH (node2:`ToClass`)<-[rel1:`HAS_REL`]-(from_class:`FromClass`) return from_class").to_a.size).to eq(1)
end
end

it 'delets has_one rel from from_node when new relation is created' do
to_node_two = ToClass.new(name: 'bar-2')
Rel2Class.new(from_node: from_node, to_node: to_node, score: 10).save
Expand Down

0 comments on commit ea53581

Please sign in to comment.