concurrency,transactions,locking,orient-db , What does the exclusive lock on storage for OrientDB entail exactly?


What does the exclusive lock on storage for OrientDB entail exactly?

Question:

Tag: concurrency,transactions,locking,orient-db

Having read the following statement from the official documentation of OrientDB:

In order to guarantee atomicity and consistency, OrientDB acquire an exclusive lock on the storage during transaction commit.

I am wondering if my understanding of the situation is correct. Here is how I assume this will work:

  1. Thread 1 opens a transaction, and reads records #1:100 to #1:200, some from class A, and some from class B (something which cannot be determined without the transaction coming to a close).
  2. Thread 1 massages the data, maybe even inserting a few records.
  3. Thread 1 starts to commit the data. As the database does not have any way to know which parts of the data might be effected by the open transaction, it will blindly block the whole storage unit and verify the @version to enforce optimistic locking on all possibly affected records.
  4. Thread 2 tries to read record #1:1 (or any other record from the whole database) and is blocked by the commit process, which is aligned, AFAIK with exclusive locking on the storage unit. This block occurs, if I'm not off, regardless of the cluster the original data resides on, since we have multi-master datasets.
  5. Thread 1 ends the commit process and the database becomes consistent, effectively lifting the lock.
  6. At this point, any thread can operate on the dataset, transactionally or otherwise, and will not be bound by the exclusive locking mechanism.

If this is the case, during the exchange highlighted in point 3 the data store, in its entirety is in an effective trance state and cannot be reached to, read from, or interacted with in any meaningful way.

I do so hope that I am missing my guess.

Disclaimer: I have not had the chance to dig into the underlying code from the rather rich OrientDB codebase. As such, this is, at its best, an educated guess and should not be taken as any sort of reference as to how OrientDB actually operates.

Possible Workarounds: Should worse come to worse and this happens to be the way OrientDB actually works, I would dearly welcome any workarounds to this conundrum. We are looking for meaningful ways that will still keep OrientDB as a viable option for an enterprise, scalable high-end application.


Answer:

In current release of OrientDB, transactions lock the storage in exclusive mode. Fortunately OrientDB works in optimistic way and this is done "only" at commit() time. So no matter when the transaction is begun.

If this is a showstopper for your use case, you could consider to:

  1. don't use transactions. In this case you'll go in parallel with no locks, but consider using indexes requires the usage of lock at index level. In case the index is a bottleneck, the most common workaround is to create X sub-classes with an index on each. OrientDB will use the index of sub-classes if needed and on CRUD operation only the specific index will be locked
  2. wait for OrientDB 3.0 where this limitation will be removed with real parallel transaction execution

Related:


Google Analytics duplicate transaction id multiple domains


google-analytics,transactions,google-tag-manager
I am implementing Google Analytics (via GTM) on multiple ecommerce sites. I need to record transactions to the client's google analytics account as well as to our single master analytics account, which accrues data for multiple sites. I am wondering if there will be any issues sending duplicate transaction ids...

Java combine explicit locks with synchronized methods


java,multithreading,concurrency,synchronization,locking
I have a thread safe class Container: public class Container { private int x; ... public synchronized int getX(); public synchronized void setX(int x); } Then I have a list of containers: List<Container> containers; I would like to iterate through the list, aquire the container's lock at each iteration and,...

Correct use of go context.Context


concurrency,go,gorilla
I just read the article: Build You Own Web Framework In Go and for sharing values among handlers I picked the context.Context and I'm using it in the following way to share values across handlers and middlewares: type appContext struct { db *sql.DB ctx context.Context cancel context.CancelFunc } func (c...

Spring 4 + JPA (Hibernate 4) + JTA transaction manager doesn't flush automatically


java,spring,hibernate,jpa,transactions
I am migrating an application from Spring 3.0.5 + JPA 2.0 to Spring 4 + JPA (Hibernate 4) I have followed the migration guide : https://github.com/spring-projects/spring-framework/wiki/Migrating-from-earlier-versions-of-the-spring-framework. The application is using a JTA transaction manager : a Jencks / GeronimoPlatformTransactionManager (because of transactions distributed on datasources and ESB). The Spring /...

java, when (and for how long) can a thread cache the value of a non-volatile variable?


java,concurrency
From this post: http://www.javamex.com/tutorials/synchronization_volatile_typical_use.shtml public class StoppableTask extends Thread { private volatile boolean pleaseStop; public void run() { while (!pleaseStop) { // do some stuff... } } public void tellMeToStop() { pleaseStop = true; } } If the variable were not declared volatile (and without other synchronization), then it would...

How do I atomically increment a variable in Swift?


swift,concurrency
I want to be able to increment a counter atomically and I can't find any reference on how to do it. Adding more information based on comments: Are you using GCD? No. I am not using GDC. Having to use a queue system to increment a number seems overkill. Do...

Custom Future objects


java,multithreading,concurrency,threadpool
I'd like to create custom Future objects. The following code works fine ThreadPoolExecutor mExecutor; Future<?> f = mExecutor.submit(new DownloadRunnable(task, itemId)); I'd like to take the return value of submit and assign it to MyFuture object, with additional calls. I've made the following changes, and getting a cast exception... Any suggestions?...

Unable to get CallableThread in RejectionHandler


java,multithreading,concurrency
I have thread pool, which will take Callable worker thread with a RejectionHandler. I need to get this Callable task in RejectionHandler but unable to get it. In this below example, I need uniqueId of Callable task for which RejectionHandler executed. In RejecitonHandler, the Runnable is casted FutureTask where I...

Why do I get random errors by using celluloid?


ruby,concurrency,celluloid
I need to make API calls to a webservice in order to retrieve date. For this purpose I created a sample in order to get familiar with celluloid. Here I ll user the openweather API for "training" purpose. The ultimate goal is to run multiple requests in concurrently. my booking...

What the difference between ExecutorService's execute and thread.run in running threads concurrently in Java?


java,multithreading,concurrency
I'm new to this concurrent programming in java and came up with following scenarios where I'm getting confusion which to use when. Scenario 1: In the following code I was trying to run threads by calling .start() on GPSService class which is a Runnable implementation. int clientNumber = 0; ServerSocket...

Clojure invokeLater null pointer


swing,concurrency,clojure
This code: (import 'javax.swing.SwingUtilities) (SwingUtilities/invokeLater (print "hi")) Causes this error: Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209) ... I don't know if this is a problem, since the code itself actually works (printing to the REPL) despite the error. However, modifying swing components does not seem to work properly: a...

erlang processes and message passing architecture


concurrency,process,erlang,messages
The task I have in hand is to read the lines of large file, process them, and return ordered results. My algorithm is: start with master process that will evaluate the workload (written in the first line of the file) spawn worker processes: each worker will read part of the...

Hibernate Query cache invalidation


java,hibernate,jpa,caching,concurrency
I am using Hibernate(with JPA) in an application that has a high write-read ratio. For caching I have enabled query-cache and hibernate second level cache(ehcache). The problem I am facing is due to automatic query cache invalidation when an update is done. Is there any way to configure query cache...

Rails on create transaction


ruby-on-rails,devise,transactions
On creating a new user (in my user model) i want to create a stripe customer as well. The two actions must only be completed if they succeed together (like i don't want a customer without a user and vice versa). For this reason I figured it would be a...

Observing changes in a BlockingCollection without consuming


c#,multithreading,concurrency,producer-consumer,blockingcollection
A consumer thread and multiple producer threads synchronize their work with a System.Collections.Concurrent.BlockingCollection<T>. The producers call blockingCollection.Add() and the consumer runs foreach (var item in blockingCollection.GetConsumingEnumerable()) {...} Now one producer wants to "flush" the buffer: The producer wants to wait until all current items have been consumed. Other producers may...

Executing more than 1000 HTTP request tasks fails


c#,concurrency,task-parallel-library,httprequest,task
I'm trying to load test an API. I'm executing a tasks at the same time, each executing an HTTP request. I use Task.WhenAll(mytasks) for waiting for all tasks to be finished. The requests look as follows: using (var response = await client.SendAsync(request).ConfigureAwait(false)) { using (var jsonResponse = await response.Content.ReadAsStreamAsync().ConfigureAwait(false)) {...

Why my mysql transaction is not working properly?


php,mysql,mysqli,transactions,database-connection
I've been reading and gathering information for 2 days already and I give up. I have no clue why my piece of simple code is not succeeding. I want to insert data from one form into two tables and YES I know there are exactly same problems described here and...

SQL Azure Connection and Transaction


transactions,sql-azure,saas
I am using SQL Azure for a Saas based asp.net application. I have avoided transactions as much as possible to prevent deadlocks for end-users. This is due to my lack of knowledge in DB Design, but I thought avoiding transaction is atleast one sure way of reducing table and row...

In Django, how to achieve repeatable reads for a transaction?


python,django,transactions,isolation-level,transaction-isolation
I have a function, that does multiple queries on the same dataset and I want to ensure all the queries would see exactly the same data. In terms of SQL, this means REPEATABLE READ isolation level for the databases that support it. I don't mind having higher level or even...

Use of serialized target queues for Concurrent queues in iOS


ios,concurrency,queue
I was going through this excellent blog post (http://www.humancode.us/2014/08/14/target-queues.html) of target threads in iOS and I could not help but wonder why do we need such a mechanism. In the example, we are specifying a serialised target queue for a custom concurrent queue. Can we not achieve the same by...

Thread blocked indefinitely in an MVar operation


haskell,concurrency,network-programming
I have been attempting to debug a problem when using multiple MVars, however to no luck. My code uses two MVars: one to store the servers current state, and another to pass network events to and from the client threads. However after connecting and disconnecting several times, the server stops...

Is spring transaction is only working in entering service method?


mysql,spring,transactions,spring-transactions
I have read many stackoverflow's pages about spring transaction. My spring transaction config is <tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/> My service is like this. @Service public class TestServiceImpl implements TestService { @Override public void testRollback() { testRollbackSecondLevel(); } @Transactional @Override public void testRollbackSecondLevel() { // any update sql in here carCostService.testUpdate(); throw...

Why does my concurrent function exit prematurely in Go?


concurrency,go
I am looking through Go Bootcamp and am reading the Go Concurrency chapter right now. I have never used concurrency before in programming and don't understand the output of this program: package main import ( "fmt" "time" ) func say(s string) { for i := 0; i < 2; i++...

Spin locked stack and memory barriers (C++)


c++,multithreading,c++11,concurrency,memory-barriers
I have a implementation spin lock: class Spinlock { public: void Lock() { while (true) { if (!_lock.test_and_set(std::memory_order_acquire)) { return; } } } void Unlock() { _lock.clear(std::memory_order_release); } private: std::atomic_flag _lock; }; I use SpinLock class in: class SpinlockedStack { public: SpinlockedStack() : _head(nullptr) { } ~SpinlockedStack() { while (_head...

SQLite3 — Return Affected Rows


jdbc,sqlite3,transactions
Supposing I have a schema with a name field and an int field. I want to get one random entry where the int value is 1, set it to 0, and return the name of the entry that was changed in a transactional manner. What's the best way to do...

Hibernate : Stale state exception


java,spring,hibernate,spring-mvc,transactions
I am working on a Spring-MVC application in which I am trying to delete an object from the database. Some days back, this error all of a sudden started, and now I am unable to delete. I checked on net, but I cannot find what am I doing wrong and...

Wildfly - Infinispan Transactions configuration


java,transactions,ejb,wildfly,infinispan
I am using Wildfly 8.2 with its included Infinispan (6.0.2) and I am trying to cache all values from some Oracle database table in an Infispan cache. In most cases, it seems to work, but sometimes it does not. When accessing the cache.values() (which also may not be a good...

Using a shared queue that workers can add tasks to


python,concurrency,multiprocessing,python-multiprocessing
I'm pretty new to python (I mainly write code in Java). I have a python script that's essentially a crawler. It calls phantomjs, which loads up the page, returns its source, and a list of urls that it found in the page. I've been trying to use Python 3's multiprocessing...

monitor log4j behaviour under load


logging,concurrency,io,log4j
I want to test my J2EE application under high load of sessions accessing different pages. This web application uses Log4J to log bunch of errors,warnings and infos. I want to test what is the side effect of this load on writing log files, especially concurrent I/O writing actions. I found...

Cakephp3 transaction find query


mysql,select,transactions,cakephp-3.0
When making a transaction in cakephp3 and adding a get() query inside all works fine. But why is a find() query not performed inside the transaction? I have the following controller in cakephp3: <?php namespace App\Controller; use Cake\Core\Configure; use Cake\Network\Exception\NotFoundException; use Cake\View\Exception\MissingTemplateException; use Cake\Network\Session; use Cake\Event\Event; use Cake\Network\Http\Client; use Cake\ORM\TableRegistry;...

Multiple NULL addition into a List in Java


java,list,concurrency,null,add
I have 2 lists and want to copy some element from one to another, i.e. there are old and new employees list I need to union 2 lists and delete the elements that include to the old list but not include in the new one. I could solve the part...

Fragment Transactions with transition - Unique transitionNames are required


android,transactions,fragment,transition,android-transitions
I want to go from a list view to the detail view and therefore, I use following OnClickListener in my list: @Override public void onClick(View view) { Bet bet = (Bet)view.getTag(); FragmentManager fm = getActivity().getSupportFragmentManager(); BetDetailFragment f = BetDetailFragment.create(bet); String tag = f.getClass().getName(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { setSharedElementReturnTransition(TransitionInflater.from(getActivity()).inflateTransition(android.R.transition.move));...

Can thread be used analogously with queue, or do they mean separate things?


objective-c,multithreading,swift,concurrency,grand-central-dispatch
I was reading through this great tutorial when I came accross the following line (as background: we were learning how to use dispatch_apply to replace a for loop and concurrently download photos): Be aware that although you have code that will add the photos in a thread safe manner, the...

akka: pattern for combining messages from multiple children


scala,concurrency,mapreduce,akka
Here's the pattern I have come across: An actor A has multiple children C1, ..., Cn. On receiving a message, A sends it to each of its children, which each do some calculation on the message, and on completion send it back to A. A would then like to combine...

What is preventing my event handler method from completing?


c#,wpf,concurrency,exception-handling,event-handling
I'm using a SerialPort, WPF for user interface, a 'ui' object to handle application logic, and a wrapper around SerialPort. The method in question is called when the SerialPort.DataReceived event is fired. It begins to run, then after reading the data, just seems to exit, even though it has tons...

Why is asynchronous network testing difficult in Objective-C/Swift?


ios,swift,asynchronous,concurrency,grand-central-dispatch
So I'm learning more about how to test asynchronous code when I come across the following: As soon as a given test method completes, XCTest methods will consider a test to be finished and move onto the next test. That means that any asynchronous code from the previous test will...

hibernate rollback not working in service layer


hibernate,postgresql,transactions,junit4,spring-4
i have issue in rollback insert/update data in postgresql database, in service layer, where as in DAO layer it is working fine. My DAO junit test Code @ContextConfiguration("classpath:datasource-context-test.xml") @RunWith(SpringJUnit4ClassRunner.class) @TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = true) @Transactional public class SellerDAOTest { @Test @Rollback(true) public void testAddSeller() { try { SellerDO sellerDO...

Are JavaFX Property objects threadsafe for multiple asynchronous writes?


java,multithreading,concurrency,javafx,javafx-8
Is it dangerous for the standard implementations of Property in JavaFX to call set methods from multiple threads? I don't really care about race conditions on the client side from reading-and-then-setting operations. I want to know if the Property itself can be corrupted internally if multiple threads call its set()...

Laravel 4.2 - Transaction rollback issue with multiple databases


php,laravel,pdo,transactions
I am experiencing issues in rolling back a transaction involving tables from multiple databases. The primary table rollback behaves as expected, but the child row remains, and is now orphaned. public function devUserCreateTest() { DB::beginTransaction(); try { $childUser = new ChildUser; // Exists in database B $parentUser = new User;...

SQlite WAL-mode in python. Concurrency with one writer and one reader


python,sqlite,concurrency
I'm trying to share a sqlite3 database between one writer process, and one reader process. However, it does not work, and it seems to me that nothing is being written in example.db. reader.py import sqlite3 from time import sleep conn = sqlite3.connect('example.db', isolation_level=None) c = conn.cursor() while True: c.execute("SELECT *...

Java 8 parallelStream for concurrent Database / REST call


java,multithreading,concurrency,parallel-processing,java-8
Here I am using Javaparallel stream to iterate through a List and calling a REST call with each list element as input. I need to add all the results of the REST call to a collection for which I am using an ArrayList. The code given below is working fine...

Moving Arc Mutex Ncurses window down thread still doesn't implement send


concurrency,rust,ncurses
I'm building an ncurses interface for a little thing I'm working on. For the input, I want to read it non blocking. I figured I could wrap the WINDOW in an Arc Mutex but this doesn't seem to work, as it still complains about send. Is this because the implementation...

JPA difference between transaction isolation and entity locking


java,database,jpa,concurrency,transactions
I have read about transaction isolation levels. It is used to prevent parallel transaction executions errors. Its quite obvious. There are also locking modes available for entities. I understand how they work. But I cant find the reason why I need locking? I have used transaction isolation levels already. Why...

EjbConetxt setRollbackOnly vs ApplicationException rollback true


java,transactions,java-ee-6
I have a method which throws an application exception with rollback true. I wonder if I have to explicitly call ejbContext.setRollbackOnly() or not? The docs here says that we need not call the EjbContext's setRollbackOnly when the exception is marked as rollback=true. In my case I catch a ApplicationException whose...

Can RPUSH and LPUSH in Redis race?


transactions,redis,race-condition
The docs at redis.io on RPUSH and LPUSH aren't clear on whether or not these operations are still O(1) and transational when pushing multiple items. For example, if two clients perform an RPUSH to the same list with multiple items, can their items become interspersed and thus out of order?...

Downside of using transaction dispose with entity framework integration testing


entity-framework,transactions,entity-framework-6.1
I am looking for a quick way to clean my tables data doing integration tests with EF. Everyone seems to wrap a transaction around its test method and dispose the transaction after the test. That way the data is never written to the table. Things like new auto ids for...

Why this indeterminate jProgressBar don't work in this simple code?


java,swing,concurrency,process,jprogressbar
I want use an indeterminate jProgressBar on a JForm but I don't know why in my code don't work. The jProgressBar must be in the indeterminate status until the thread receives a latch.await() signal. This is the simple part of code when I push a button: private void jButton5ActionPerformed(java.awt.event.ActionEvent evt)...

Java 5 Multi threading, catch thread exceptions


java,multithreading,exception,concurrency,java-5
I've got a class that generates threads (file i/o). I need to catch exceptions in the thread - I don't want to do anything fancy, I want to kill the main thread, rather, stop processing altogether so it can start over. If I catch the exceptions in the thread, that's...

Transactions in php function or in mysql stored procedure?


php,mysql,pdo,transactions
What is better way to begin a transaction? Inside procedures or PHP functions? For example I calling MySQL procedure like this: function sendLeaguesToDb(){ $leagues = ""; try{ $this->PDO->beginTransaction(); $stmt = $this->PDO->prepare("call insupd_Leagues(:id,:name,:country,:sport_id,:his_data,:fixtures,:livescore, :numofmatches,:latestmatch)"); $leagues=$this->soccer->GetAllLeagues(); foreach($leagues as $key=>$value){ $stmt->bindParam(':id',$value->Id); $stmt->bindParam(':name',$value->Name);...