locking

Lock whole database?

断了今生、忘了曾经 提交于 2020-01-15 06:38:09
问题 I have really odd user requirement. I have tried to explain to them there are much better ways of supporting their business process and they don't want to hear it. I am tempted to walk away but I first want to see if maybe there is another way. Is there any way that I can lock a whole database as opposed to row-lock or table-lock. I know I can perhaps put the database into single-user mode but that means only one person can use it at a time. I would like many people to be able to read at a

Explain locking behavior in SQL Server

谁都会走 提交于 2020-01-15 06:35:27
问题 Why is that, with default settings on Sql Server (so transaction isolation level = read committed), that this test: CREATE TABLE test2 ( ID bigint, name varchar(20) ) then run this in one SSMS tab: begin transaction SH insert into test2(ID,name) values(1,'11') waitfor delay '00:00:30' commit transaction SH and this one simultaneously in another tab: select * from test2 requires the 2nd select to wait for the first to complete before returning?? We also tried these for the 2nd query: select *

popen - locks or not thread safe?

寵の児 提交于 2020-01-15 06:30:34
问题 I've seen a few implementations of popen()/pclose(). They all used a static list of pids, and no locking: static int *pids; static int fds; if (!pids) { if ((fds = getdtablesize()) <= 0) return (NULL); if ((pids = malloc(fds * sizeof(int))) == NULL) return (NULL); memset(pids, 0, fds * sizeof(int)); } Or this, supposedly NetBSD: static struct pid { struct pid *next; FILE *fp; pid_t pid; } *pidlist; /* Link into list of file descriptors. */ cur->fp = iop; cur->pid = pid; cur->next = pidlist;

popen - locks or not thread safe?

为君一笑 提交于 2020-01-15 06:30:26
问题 I've seen a few implementations of popen()/pclose(). They all used a static list of pids, and no locking: static int *pids; static int fds; if (!pids) { if ((fds = getdtablesize()) <= 0) return (NULL); if ((pids = malloc(fds * sizeof(int))) == NULL) return (NULL); memset(pids, 0, fds * sizeof(int)); } Or this, supposedly NetBSD: static struct pid { struct pid *next; FILE *fp; pid_t pid; } *pidlist; /* Link into list of file descriptors. */ cur->fp = iop; cur->pid = pid; cur->next = pidlist;

Php Script to check MySQL TABLE LOCK status

一曲冷凌霜 提交于 2020-01-15 05:47:07
问题 I use mysqldump for MySQL Backup. mysqldump --lock-tables.... The DB is about 2GB, hence mysqldump takes a long time. If anyone tries to access the DB during backup, I would like to flash a message saying "the DB is being backed-up, please return back after 10 minutes" My questions is using PHP script, how can I check if mysql table is locked or not. Thank you in advance. Best regards, Sanjay 回答1: Prefer method will be setup replication, and mysqldump on the slave instead on master (assuming

Lock Cells after Data Entry

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-15 05:24:08
问题 I have a spreadsheet that is edited by multiple users. To prevent tampering with previous data the cells are locked once data has been entered and the file saved. I have a few small bugs in the code though: Even if the user has saved manually and then exits the application they are still prompted to save again. The cells should be locked after a save when the application is running and not just when it is exited. Previously I had this code in the before_save event but the cells were being

How to lock tables with codeigniter?

你说的曾经没有我的故事 提交于 2020-01-15 03:58:34
问题 I have to run this sql routine in a model: $this->db->query('LOCK TABLE orders WRITE'); $this->db->query('TRUNCATE TABLE orders'); $this->db->query('INSERT INTO orders SELECT * FROM orders_tmp'); $this->db->query('UNLOCK TABLES'); but I get this error: Error Number: 1192 Impossible to execute the requested command: tables under lock or transaction running TRUNCATE TABLE orders I use MyISAM as DB engine on this table. Could you please help me? 回答1: To perform many INSERT and SELECT operations

How to lock tables with codeigniter?

假装没事ソ 提交于 2020-01-15 03:58:21
问题 I have to run this sql routine in a model: $this->db->query('LOCK TABLE orders WRITE'); $this->db->query('TRUNCATE TABLE orders'); $this->db->query('INSERT INTO orders SELECT * FROM orders_tmp'); $this->db->query('UNLOCK TABLES'); but I get this error: Error Number: 1192 Impossible to execute the requested command: tables under lock or transaction running TRUNCATE TABLE orders I use MyISAM as DB engine on this table. Could you please help me? 回答1: To perform many INSERT and SELECT operations

Java: Do all mutable variables need to be volatile when using locks?

余生颓废 提交于 2020-01-14 13:51:30
问题 Does the following variable, x, need to be volatile? Or does the manipulation within a utils.concurrent lock perform the same function as a synchronized block (ensuring it's written to memory, and not stored in cpu cache)? myMethod(){ myLock.lock(); x++; myLock.unlock(); } 回答1: Such variables only need to be volatile if they're accessed elsewhere without a lock. For example, as a fast read-only access to a size variable. The lock methods do serve the same purpose as a synchronized block. See

Do i need a lock on a list? C#

喜欢而已 提交于 2020-01-14 12:48:28
问题 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 if my main thread wants to read the data in the list (never write) do i need a lock for that? i'm sure i dont but i would like to ask before implementation.