Are there well-known best practices for synchronizing tasks across a server farm? For example if I have a forum based website running on a server farm, and there are two moderators trying to do some action which requires writing to multiple tables in the database, and the requests of those moderators are being handled by different server...
Assume:
A. C++ under WIN32.
B. A properly aligned volatile integer incremented and decremented using InterlockedIncrement() and InterlockedDecrement().
__declspec (align(8)) volatile LONG _ServerState = 0;
If I want to simply read _ServerState, do I need to read the variable via an InterlockedXXX function?
For instance, I have seen...
Is there any way to lock on an integer in C#, integers can not be used with lock because they are boxed (and lock only locks on references).
The scenario is as follows, I have that forum based website which support moderation, I want to make sure that no more than one moderator can moderate a post at a time, for this I want to use the I...
On constrained devices, I often find myself "faking" locks between 2 threads with 2 bools. Each is only read by one thread, and only written by the other. Here's what I mean:
bool quitted = false, paused = false;
bool should_quit = false, should_pause = false;
void downloader_thread() {
quitted = false;
while(!should_quit) {
...
I filled several list<> with default values, stuck them into a struct then pass the struct into several threads. Each thread has a different range so thread 1 would access list[0 to 199] thread 2 would access [200 - 400] etc. Would i need a lock? and when do i need it? i can access the list with my multiple threads w/o using a lock. But...
I have a flash application that I am going to put up on my website shortly. I want to be able to "lock it" to the site to prevent:
Hosting the .SWF on another site (after an illicit download), and
Preventing the .SWF from opening if included in an iFrame on another site
While allowing:
A whitelist of sites to be passed through/enab...
We have had an issue with a block of code that responds poorly in the face of slow databases (It craps the bed on a query timeout). We have created a patch, and are in the process of running it through regression.
We can't get a timeout. I've opened a transaction from SQL Mgmt Studio and updated every row to lock them, but that doesn't ...
Ive narrowed down to this method but i don't understand why its locking the file. I believe you could use something like
using( something)
{
//do stuff here
}
But im not sure that would A) solve the issue or B) be the correct way if it did.
any ideas?
[DllImport("user32.dll", CharSet = CharSet.Auto)]private static extern Int32 Syst...
I've been playing with collections and threading and came across the nifty extension methods people have created to ease the use of ReaderWriterLockSlim by allowing the IDisposable pattern.
However, I believe I have come to realize that something in the implementation is a performance killer. I realize that extension methods are not sup...
I watched in horror this morning as a script, running on two different machines, happily loaded, updated, and saved. I'm running ruby 1.8.6, AR 2.2.2. I started playing with some test cases and found reduced it to a minimal reproduction case:
irb(main):059:0> first = Job.find :first
=> #<Job id: 323, lock: 8, worker_host: "second">
i...
Somehow, I always get these on Fridays.
My earlier question was regarding the same problem, but I can now narrow things down a bit:
I've been playing with this all day, trying to make sense of it. I have a table with a lock_version colum, specified thus:
add_column :jobs, :lock_version, :integer, :default=>0
And I do something like...
The ConcurrentHashMap of JDK uses a lock-striping technique. It is a nice idea to minimize locking overhead. Are there any other libraries or tools that take advantage of it?
For example, does database engine use it?
If the technique is not so much useful in other areas, what is the limitation of it?
...
This is an offshoot of this question but with a few constraints removed.
I have a system where I need to manage file locking. I need to be able to lock a file (shared read locking) in one thread and then unlock it in another. More accurately, I can't be sure what thread it will be unlocked in or even if the creating thread is still arou...
I have a MDB (Message driven bean) that receives messages with String which represent a word. Also I have a table in the database. The MDB should store in the table, the words and the number of times each word was received (counter).
The problem is that to get better performance the MDB started in many instances and when the same new wo...
Okay, some background first. We needed an inter-process reader/writer lock. We decided to use a file and lock the first byte using LockEx and UnlockEx. The class creates a file in the system temp folder when it is created. The file is created with readwrite access and share read|write|delete. We also specify DeleteOnClose so we don'...
I have a script that was generated in SQL Server 2008, but I need to execute it against a SQL Server 2005 database.
What would an equivalent statement for the following be in SQL Server 2005?
ALTER TABLE dbo.Event SET (LOCK_ESCALATION = TABLE)
...
I understand this is a VERY vague question, so forgive me.
A company I used to work for has contacted me saying that since they've upgraded to SQL Server 2008, they've been encountering a ton of "locking" issues.
I really don't know what this means. I don't even know how to see these "locking" errors in SQL Server. This was not my area...
Asking this question with C# tag, but if it is possible, it should be possible in any language.
Is it possible to implement a doubly linked list using Interlocked operations to provide no-wait locking? I would want to insert, add and remove, and clear without waiting.
...
Is it important that I lock around the queue?
public abstract class ExpiringCache<TKey,TValue> : IDisposable
{
protected readonly object locker = new object();
protected readonly Dictionary<TKey, TValue> cache =
new Dictionary<TKey, TValue>();
private readonly Queue<KeyValuePair<TKey, long>> queue =
new Qu...
We had a problem today on our dev server where a process locked one table, stopping all other queries on that table to work. When running sql_who2 the blkBy columns value was -2, but the -2 was not in the process list.
When running DBCC INPUTBUFFER (-2) I got the exception Invalid SPID -2 specified.
When running beta_lockinfo I see all...