476968e2c8
Concurrent access to the same query module had a race condition on the pointer that was used to handle the custom memory management. With this commit, a mapping has been added to keep information about what thread used the pointer to handle the memory resources. This should be fine since the respected query executions are running on a dedicated thread. Access to the mapping itself is threadsafe. A simple RAII wrapper for the mapping container has also been added for simpler client-side use.
20 lines
1.0 KiB
Python
20 lines
1.0 KiB
Python
import sys
|
|
|
|
import pytest
|
|
from client import *
|
|
|
|
query = "MATCH (my_person:Person)-[:FOLLOW]->(follow_person:Person) MATCH (follow_person)-[: LIKE]->(post:Post) WHERE post.indexedAt IS NOT NULL AND NOT exists((post)-[:ROOT]->(:Post)) WITH localDateTime() - post.indexedAt as duration, post, follow_person WHERE duration.day < 5 WITH (duration.day * 24) + duration.hour as hour_age, post, follow_person ORDER BY post.indexedAt DESC LIMIT 500 MATCH(: Person) - [l: LIKE] -> (post) WITH count(l) as likes, hour_age, post, follow_person CALL libmodule_test.hacker_news(likes, 123, 4.1) YIELD score RETURN ID(post), post.uri, hour_age, likes, score, follow_person ORDER BY score DESC, hour_age ASC, post.indexedAt DESC LIMIT 100;"
|
|
|
|
|
|
def test_concurrent_module_access(client):
|
|
client.initialize_to_execute(query, 200)
|
|
client.initialize_to_execute(query, 200)
|
|
client.initialize_to_execute(query, 200)
|
|
|
|
success = client.execute_queries()
|
|
assert success
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(pytest.main([__file__, "-rA"]))
|