locking

Why gives mysql the error ER_TABLE_NOT_LOCKED while I just locked the table?

风格不统一 提交于 2019-12-23 23:53:29
问题 I have some code that does a LOCK TABLE on a table in my database. After the lock, I do a SELECT from this same table. My mysql API interface gives the following error: mysqlsel/db server: Table 'Mytable' was not locked with LOCK TABLES According some googling, this relays to the error code: ER_TABLE_NOT_LOCKED Why would this code generate this error? I would not expect it to give an error if I do not lock it at all, and I certainly do not expect an error if I lock it either. 回答1: I think I

Boost lock_guard<boost::mutex> Throws EINVAL Exception

让人想犯罪 __ 提交于 2019-12-23 23:15:32
问题 I have some static user data like: private: static std::map<unsigned long, UserDataSharedPtr> userStore_; static boost::mutex mutexUserData; public: static void RemoveUserData(unsigned long id) { boost::lock_guard<boost::mutex> lock(mutexUserData); std::map<unsigned long, UserDataSharedPtr>::iterator it = userStore_.find(id); if (it != userStore_.end()) { userStore_.erase(it); } } static void AddUserData(unsigned long id, UserDataSharedPtr ud) { boost::lock_guard<boost::mutex> lock

Possible locking issue in Tkinter application

老子叫甜甜 提交于 2019-12-23 23:00:57
问题 I'm trying to create a sliding menubar for my tkinter application, but I've run into an issue that I suspect comes from my not locking a thread properly. While I have been dabbling with Python for a while, I'm relatively new to both tkinter and threaded applications, and I hoped someone here might be able to shed a little light on what I'm doing wrong. My code is as follows: class MenuBar(): def slide_out(self, event = None): def helper(): while self.canvas.coords(self.bg)[0] > 100 and self

Can PostgreSQL 9.1 leak locks? (out of shared memory/increase max_pred_locks_per_transaction)

南笙酒味 提交于 2019-12-23 22:54:47
问题 We recently upgraded to postgresql 9.1.6 (from 8.3). Our test server indicated that the max_pred_locks_per_transaction should be set at least as high as 900 (which is way beyond the recommended setting of 64). We're now in production, and I've had to increase this parameter many times, as our log will start filling with: ERROR: 53200: out of shared memory HINT: You might need to increase max_pred_locks_per_transaction. With a client connection setting of 600 (but a pooling system that never

Python GIL prevent CPU usage to exceed 100% in multiple core machine?

懵懂的女人 提交于 2019-12-23 19:51:27
问题 Many references say that, Python GIL lower down the performance of multi threading code in multi core machine, since each thread will need to acquire the GIL before executioin. In other words, it looks like GIL make a multi threading Python program to a single thread mode in fact. For example: (1) Thread A get GIL, execute some time, release GIL (2) Thread B get GIL, execute some time, release GIL ... However, after some simple experiments, I found that although GIL lower down the performance

PowerShell: Set-Content having issues with “file already in use”

允我心安 提交于 2019-12-23 19:43:30
问题 I'm working on a PowerShell script that finds all the files with PATTERN within a given DIRECTORY, prints out the relevant lines of the document with the PATTERN highlighted, and then replaces the PATTERN with a provided REPLACE word, then saves the file back. So it actually edits the file. Except I can't get it to alter the file, because Windows complains about the file already being open. I tried several methods to solve this, but keep running into the issue. Perhaps someone can help: param

Interlocked.Increment vs lock in debug vs release mode

梦想的初衷 提交于 2019-12-23 18:40:27
问题 I was testing how Interlocked.Increment and lock behave on my computer's architecture because I read the following lines in this article. As rewritten with Interlocked.Increment, the method should execute faster, at least on some architectures. Using the following code I get convinced that it's worth to review locks in my projects. var watch = new Stopwatch(); var locker = new object(); int counter = 0; watch.Start(); for (int i = 0; i < 100000000; i++) { lock (locker) { counter++; } } watch

Thread safe way of reading a value from a dictionary that may or may not exist

∥☆過路亽.° 提交于 2019-12-23 18:11:32
问题 So, I've been spoiled by ConcurrentDictionary and it's awesome TryGetValue method. However, I'm constrained to using only regular Dictionary because this is in a portable class library targeting phone and other platforms. I'm trying to write a very limited subset of a Dictionary and exposing it in a thread-safe manner. I basically need something like GetOrAdd from ConcurrentDictionary. Right now, I have this implemented like: lock (lockdictionary) { if (!dictionary.ContainsKey(name)) { value

ReentrantReadWriteLock multiple reading threads

元气小坏坏 提交于 2019-12-23 15:23:59
问题 Good Day I have a question relating ReentrantReadWriteLocks. I am trying to solve a problem where multiple reader threads should be able to operate in parallel on a data structure, while one writer thread can only operate alone (while no reader thread is active). I am implementing this with the ReentrantReadWriteLocks in Java, however from time measurement it seems that the reader threads are locking each other out aswell. I don't think this is supposed to happen, so I am wondering if I

Good advices to use EF in a multithread program?

∥☆過路亽.° 提交于 2019-12-23 10:30:11
问题 Have you got some good advices to use EF in a multithread program ? I have 2 layers : a EF layer to read/write into my database a multithread service which uses my entities (read/write) and makes some computations (I use Task Parallel Library in the framework) How can I synchronize my object contexts in each thread ? Do you know a good pattern to make it work ? 回答1: Good advice is - just don't :-) EF barely manages to survive one thread - the nature of the beast. If you absolutely have to use