locking

Does using a lock have better performance than using a local (single application) semaphore? [closed]

岁酱吖の 提交于 2019-12-10 17:20:06
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 8 months ago . Does using a lock have better performance than using a local (single application) semaphore? I read this blog from msdn : Producer consumer solution on msdn and I didn't like their solution to the problem because there are always 20 elements left in the queue. So instead, I

postgresql “idle in transaction” with all locks granted

谁说我不能喝 提交于 2019-12-10 16:39:08
问题 A very simple delete (by key) on a small table (700 rows) every now and then stays "idle in transaction" for minutes (takes milliseconds usually) even though all the locks are marked as "granted". What can I do to pinpoint what causes it? I'm using this select: SELECT a.datname, c.relname, l.transactionid, l.mode, l.GRANTED, a.usename, a.waiting, a.query, a.query_start, age(now(), a.query_start) AS "age", a.pid FROM pg_stat_activity a JOIN pg_locks l ON l.pid = a.pid JOIN pg_class c ON c.oid

Deleting rows cause lock timeout

天大地大妈咪最大 提交于 2019-12-10 16:37:36
问题 I keep getting these errors when trying to delete rows from a table. The special case here is that I may be running 5 processes at the same time. The table itself is an Innodb table with ~4.5 million rows. I do not have an index on the column used in my WHERE clause. Other indices are working as supposed to. It's being done within a transcation, first I delete records, then I insert replacing records, and only if all records are inserted should the transaction be commited. Error message:

Does a lock statement around multiple statements ensure that all the changes are visible to other threads (provided they enter the same mutex)?

拥有回忆 提交于 2019-12-10 16:22:50
问题 If you have multiple assignments of shared variables inside one lock code block, does it necessarily mean that all these changes are immediately visible to other threads, potentially running on other processors once they enter a lock statement on the same object - or is there no such guarantees? A lot of the examples out there shows a single "set" or "get" of a common variable and goes into detail of memory barriers but what happens if a more complicated set of statements are inside?

MySQL UPDATE operations on InnoDB occasionally timeout

杀马特。学长 韩版系。学妹 提交于 2019-12-10 16:09:14
问题 These are simple UPDATE s on very small tables in an InnoDB database. On occasion, an operation appears to lock, and doesn't timeout. Then every subsequent UPDATE ends with a timeout. The only recourse right now is to ask my ISP to restart the daemon. Every field in the table is used in queries, so all the fields are indexed, including a primary. I'm not sure what causes the initial lock, and my ISP doesn't provide enough information to diagnose the problem. They are reticent about giving me

How do I use `lock_hash_recurse` in Perl?

邮差的信 提交于 2019-12-10 16:07:43
问题 In continue to the discussion here, I'm havind some trouble with lock_hash_recurse as illustrated below: #!/usr/bin/perl use strict; use warnings; use Data::Dumper; use Hash::Util qw (lock_keys); my $hashref = {A=>1, B=>{CC=>22, DD=>33}}; lock_keys(%{$hashref}); # this is OK Hash::Util::lock_hash_recurse(%{$hashref}); # this fails: "Use of uninitialized value in string eq at /usr/lib/perl/5.10/Hash/Util.pm line 153." From what I can tell, reftype returns undef ... is that a bug in lock_hash

How can I ensure only one copy of a Perl script is running at a time?

吃可爱长大的小学妹 提交于 2019-12-10 15:51:11
问题 I need to ensure that only one copy of my Perl script is running at a time. According to the suggestions here I wrote a sub to do the check: sub check_instances { open my $fh, '<', $0 or die $!; unless (flock($fh, LOCK_EX|LOCK_NB)) { print "$0 is already running. Exiting.\n"; exit 1; } } But it doesn't work. What can be the issue? 回答1: You're using a lexical filehandle scoped inside the sub. When check_instances returns, the filehandle is automatically closed, which releases the lock. So you

F#: only do one action once for the first event, without mutability/locking?

大憨熊 提交于 2019-12-10 15:45:00
问题 I have this code that downloads a file and tells me in the console how big is the file: use webClient = new WebClient() let lockObj = new Object() let mutable firstProgressEvent = true let onProgress (progressEventArgs: DownloadProgressChangedEventArgs) = lock lockObj (fun _-> if (firstProgressEvent) then let totalSizeInMB = progressEventArgs.TotalBytesToReceive / 1000000L Console.WriteLine ("Starting download of {0}MB...", totalSizeInMB) firstProgressEvent <- false ) webClient

Is join insert/update on MySQL an atomic operation?

馋奶兔 提交于 2019-12-10 15:07:53
问题 In a Mysql database with every table based on InnoDB with Autocommit enabled, will queries with subqueries and/or joins be atomic? Examples: INSERT INTO users SELECT (x,y,z) FROM users, comments WHERE users.id = comments.user_id; (joins) UPDATE users, comments SET users.x = x1 WHERE users.age > 30; (joins) UPDATE users, comments SET users.x = x1, comments.y = y1 WHERE users.age > 30; (joins) UPDATE users, comments SET users.x = x1, comments.y = y1 WHERE users.id IN (SELECT id FROM users WHERE

Getting account 'locked' status in SQL Server

冷暖自知 提交于 2019-12-10 14:56:20
问题 I want to unlock one account in SQL Server. Before unlocking I have to check whether that account is locked or not. I want to unlock only if the account is locked. Is there any SQL query or stored procedure to get the "Locked" status of SQL user? 回答1: Posting Answer on Behalf of Alex K. SELECT LOGINPROPERTY('loginname', 'IsLocked') 回答2: Do you mean a login name that has Login: Denied ? If so you can: SELECT is_disabled from sys.server_principals WHERE name = @loginname 来源: https:/