locking

skip-lock-tables and mysqldump

北战南征 提交于 2019-12-03 16:05:10
问题 Daily we run mysql dumps on about 50 individual databases, package them up and then store them offsite. Some of these databases are rather large and contain myisam tables (which CANNOT be changed so suggesting it is pointless).. I have been reading up on using the skip-lock-tables option when doing a dump but have not read what the downside would be. All I see are basically different iterations of "it could have adverse effects if data is inserted to a table while it is dumping." What are

Swapping a running jar at runtime

前提是你 提交于 2019-12-03 15:59:33
I am building an update system in which I need to be able to replace a referenced jar of a running application jar at runtime. However, I am running into file locking issues on Windows when trying to perform file utility functions on the jar such as 'setLastModified'. After some googling I found this snippet... What I found in my research is that the standard ClassLoader implementation never closes a jar file once it has been opened. It also only loads resources from the jar file as needed. So at any particular time, there may be Classes in the jar file that have not been loaded into memory.

linux thread synchronization

一世执手 提交于 2019-12-03 14:53:37
问题 I am new to linux and linux threads. I have spent some time googling to try to understand the differences between all the functions available for thread synchronization. I still have some questions. I have found all of these different types of synchronizations, each with a number of functions for locking, unlocking, testing the lock, etc. gcc atomic operations futexes mutexes spinlocks seqlocks rculocks conditions semaphores My current (but probably flawed) understanding is this: semaphores

Platform independent file locking?

三世轮回 提交于 2019-12-03 14:37:04
I'm running a very computationally intensive scientific job that spits out results every now and then. The job is basically to just simulate the same thing a whole bunch of times, so it's divided among several computers, which use different OSes. I'd like to direct the output from all these instances to the same file, since all the computers can see the same filesystem via NFS/Samba. Here are the constraints: Must allow safe concurrent appends. Must block if some other instance on another computer is currently appending to the file. Performance does not count. I/O for each instance is only a

Releasing Windows file share locks

筅森魡賤 提交于 2019-12-03 14:31:28
问题 This problem crops up every now and then at work. Our build machine can have it's files accessed via a normal windows file share. If someone browses a folder remotely on the machine, and leaves the window open overnight, then the build fails (as it has done now). The explorer window left opened points at one of the sub folders in the source tree. The build deletes the source, and does a clean checkout before building. The delete is failing. Right now, I'd like to get the build to work. I'm

C# Am i using lock correctly?

廉价感情. 提交于 2019-12-03 14:13:15
I'm currently trying to write a thread-safe logger class. I'm not very familiar with correct design and best practices in this area. Is there a flaw in my code? public class WriteStuff { private readonly StreamWriter m_Writer; private readonly object m_WriteLock = new object (); public WriteStuff(String path) { m_Writer = File.CreateText (path); m_Writer.WriteLine ("x"); m_Writer.Flush (); } public void ListenTo(Foo foo) { foo.SomeEvent += new EventHandler<SomeArgs> (Foo_Update); } private void Foo_Update(object sender, SomeArgs args) { lock (m_WriteLock) { m_Writer.WriteLine (args); m_Writer

Java Memory Model: reordering and concurrent locks

本小妞迷上赌 提交于 2019-12-03 14:06:07
The java meomry model mandates that synchronize blocks that synchronize on the same monitor enforce a before-after-realtion on the variables modified within those blocks. Example: // in thread A synchronized( lock ) { x = true; } // in thread B synchronized( lock ) { System.out.println( x ); } In this case it is garanteed that thread B will see x==true as long as thread A already passed that synchronized -block. Now I am in the process to rewrite lots of code to use the more flexible (and said to be faster) locks in java.util.concurrent , especially the ReentrantReadWriteLock . So the example

MySQL atomic operations and table locking

亡梦爱人 提交于 2019-12-03 13:44:05
I have a website where users can purchase tickets, but ticket quantities are usually limited and go quickly. I'm trying to implement an escrow system such that a user can click that they want x number of tickets, at which point I will put them in an escrow state. That gives them several minutes to enter their credit card information and complete the purchase. I have three relevant tables: events, tickets, and escrow. A row in the events table describes the event itself, including the maximum number of tickets available. The tickets table holds the following: user_id : the user that purchased

Best way to prevent race condition in multiple chrome.storage API calls?

荒凉一梦 提交于 2019-12-03 13:24:38
问题 Something requests a task Something else pulls the task list out of storage, and checks if there are tasks there. If there are tasks it removes one and the smaller "task list" is put back in storage. Between steps 2 and 3 a race condition can occur if multiple requests occur, and the same task will be served twice. Is the correct resolution to "lock" the "tasks table" while a single task is "checked out", to prevent any other requests? What is the solution with the least performance impact,

How do I create an Activity that is visible on top of the lock screen

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-03 13:06:15
问题 I'm receiving an incoming C2DM notification while the screen is locked. I'd like to wake up the screen and display the notification message on top of the lock screen using an Activity. I'm launching the notification Activity from my C2DM BroadcastReceiver as follows: Intent new_intent= new Intent().setClass( context, EIAlertDialog.class ); new_intent.addFlags( Intent.FLAG_ACTIVITY_CLEAR_TOP ); new_intent.addFlags( Intent.FLAG_ACTIVITY_NEW_TASK ); context.startActivity( new_intent ); and