You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: pages/client-libraries/python.mdx
+10-1
Original file line number
Diff line number
Diff line change
@@ -545,6 +545,9 @@ With sessions, you can run:
545
545
##### Managed transactions
546
546
547
547
To create a managed transaction, use `Session.execute_read()` procedure for read queries and `Session.execute_write()` procedure for write queries.
548
+
As of Memgraph version 3.2, queries are categorized as read or write and the corresponding storage access is taken. This allows for better query parallelization and higher throughput.
549
+
An exception will be thrown if the user tries to execute a write query inside a read transaction. See ... for more details.
550
+
548
551
549
552
```python
550
553
defmatch_user(tx, name):
@@ -581,6 +584,10 @@ To maintain multiple concurrent transactions, use [multiple concurrent sessions]
581
584
With explicit transactions, you can get **complete control over transactions**. To begin a transaction, run `Session.begin_transaction()` procedure and to run a transaction, use `Transaction.run()` procedure.
582
585
Explicit transactions offer the possibility of explicitly controlling the end of a transaction with `Transaction.commit()`, `Transaction.rollback()` or `Transaction.close()` methods.
583
586
587
+
As of Memgraph version 3.2, queries are categorized as read or write and the corresponding storage access is taken. This allows for better query parallelization and higher throughput.
588
+
Explicit transactions can cover a number of individual queries, but storage access is given at the start. For best performance, the user needs to declare whether the transaction should use read or write access.
589
+
This can be done by setting the session's `default_access_mode` to `"r"` or `"w"`. This will in turn set the access mode of a transaction created via the `begin_transaction` function. Note that `execute_read` and `execute_write` will override the session's default access.
590
+
584
591
Use explicit transaction if you need to **distribute Cypher execution across multiple functions for the same transaction** or if you need to **run multiple queries within a single transactions without automatic retries**.
585
592
586
593
The following example shows how to explicitly control the transaction of changing account balances based on a token transfer:
with client.session(database="memgraph") as session:
620
+
with client.session(database="memgraph", default_access_mode="w") as session:
614
621
tx = session.begin_transaction()
615
622
616
623
try:
@@ -675,6 +682,8 @@ In the above example, if John's account balance is changed to a number less than
675
682
676
683
Implicit or auto-commit transactions are the simplest way to run a Cypher query since they won't be automatically retried as with `execute_query()` procedure or managed transactions.
677
684
With implicit transactions, you don't have the same control of transaction as with explicit transactions, so they are mostly used for quick prototyping.
685
+
As of Memgraph version 3.2, queries are categorized as read or write and the corresponding storage access is taken. This allows for better query parallelization and higher throughput.
686
+
Access mode is automatically determined when executing single queries through implicit transactions.
678
687
679
688
To run an implicit transaction, use the `Session.run()` method:
Copy file name to clipboardExpand all lines: pages/help-center/errors/transactions.mdx
+6-4
Original file line number
Diff line number
Diff line change
@@ -119,15 +119,17 @@ Here are the [instructions](/configuration/configuration-settings#using-flags-an
119
119
120
120
Here are the storage access error messages you might encounter:
121
121
122
-
1.**Cannot access storage, unique access query is running. Try again later.**
122
+
1.**Cannot get shared access storage. Try stopping other queries that are running in parallel.**
123
123
2.**Cannot get unique access to the storage. Try stopping other queries that are running in parallel.**
124
+
3.**Cannot get read only access to the storage. Try stopping other queries that are running in parallel.**
124
125
125
126
### Understanding storage access timeout
126
127
127
-
Storage access timeouts occur during query preparation when the query execution engine cannot get the required type of access to the storage. There are two types of storage access:
128
+
Storage access timeouts occur during query preparation when the query execution engine cannot get the required type of access to the storage. There are three types of storage access:
128
129
129
-
-**Shared access**: Multiple queries can have shared access at the same time, but shared access cannot be granted while a query with unique access is running.
130
-
-**Unique access**: Only one query can have unique access at a time, and no other query can have any type of access during that period.
130
+
-**Shared access**: Multiple queries can have shared access at the same time. These queries are marked with a read or write type, allowing Memgraph to efficiently execute multiple operations in parallel without conflicts.
131
+
-**Unique access**: Only one query can have unique access at a time, and no other access type can be granted during that period.
132
+
-**Read-only access**: Queries with read-only access allow other read queries to run in parallel but forbid any write operations or unique access queries.
131
133
132
134
These timeouts prevent worker starvation and database blocking that could occur if queries were to wait indefinitely for storage access.
0 commit comments