Search Results

Search found 1071 results on 43 pages for 'pessimistic locking'.

Page 13/43 | < Previous Page | 9 10 11 12 13 14 15 16 17 18 19 20  | Next Page >

  • How do I can linux flock command to prevent another root process deleting a file?

    - by Danmaxis
    Hello there, I would like to prevent one of my root process from deleting a certaing file. So I came across the flock command, it seems to fit my need, but I didnt get its sintax. If I only indicate a shared lock, it doesnt work: flock -s "./file.xml" If I add a timeout parameter, it still doesnt work flock -s -w5 "./file.xml" It seems that way, it fits in flock [-sxun][-w #] fd# way. (What is this fd# parameter?) So, I tried the flock [-sxon][-w #] file [-c] command Using flock -s -w5 "./file.xml" -c "tail -3 ./file.xml" and it worked, tail command at ./file.xml was executed. But I would like to know, does the lock end after the command or does it last 5 seconds after the end of the command execution? My main question is, how can I prevent another root process deleting a file in linux?

    Read the article

  • GAE update different fields of the same entity

    - by bach
    Hi, UserA and UserB are changing objectA.filedA objectA.filedB respectively and at the same time. Because they are not changing the same field one might think that there are no overlaps. Is that true? or the implementation of pm.makePersistnace() actually override the whole object... good to know...

    Read the article

  • Mysql- "FLUSH TABLES WITH READ LOCK" started automatically

    - by ming yeow
    I would like to understand how this happened. I was running a query that would take a long time, but should not lock up any table. However, my dbs were practically down - it seems like it was being locked up by "FLUSH TABLES WITH READ LOCK" 03:21:31 select type_id, count(*) from guid_target_infos group by type_id 02:38:11 select type_id, count(*) from guid_infos group by type_id 02:24:29 FLUSH TABLES WITH READ LOCK But i did not start this command. can someone tell me why it was started automatically?

    Read the article

  • How do I avoid a race condition in my Rails app?

    - by Cathal
    Hi, I have a really simple Rails application that allows users to register their attendance on a set of courses. The ActiveRecord models are as follows: class Course < ActiveRecord::Base has_many :scheduled_runs ... end class ScheduledRun < ActiveRecord::Base belongs_to :course has_many :attendances has_many :attendees, :through => :attendances ... end class Attendance < ActiveRecord::Base belongs_to :user belongs_to :scheduled_run, :counter_cache => true ... end class User < ActiveRecord::Base has_many :attendances has_many :registered_courses, :through => :attendances, :source => :scheduled_run end A ScheduledRun instance has a finite number of places available, and once the limit is reached, no more attendances can be accepted. def full? attendances_count == capacity end attendances_count is a counter cache column holding the number of attendance associations created for a particular ScheduledRun record. My problem is that I don't fully know the correct way to ensure that a race condition doesn't occur when 1 or more people attempt to register for the last available place on a course at the same time. My Attendance controller looks like this: class AttendancesController < ApplicationController before_filter :load_scheduled_run before_filter :load_user, :only => :create def new @user = User.new end def create unless @user.valid? render :action => 'new' end @attendance = @user.attendances.build(:scheduled_run_id => params[:scheduled_run_id]) if @attendance.save flash[:notice] = "Successfully created attendance." redirect_to root_url else render :action => 'new' end end protected def load_scheduled_run @run = ScheduledRun.find(params[:scheduled_run_id]) end def load_user @user = User.create_new_or_load_existing(params[:user]) end end As you can see, it doesn't take into account where the ScheduledRun instance has already reached capacity. Any help on this would be greatly appreciated.

    Read the article

  • Do really need a count lock on Multi threads with one CPU core?

    - by MrROY
    If i have some code looks like this(Please ignore the syntax, i want to understand it without a specified language): count = 0 def countDown(): count += 1 if __name__ == '__main__': thread1(countDown) thread2(countDown) thread3(countDown) Here i have a CPU with only one core, do i really need a lock to the variable count in case of it could be over-written by other threads. I don't know, but if the language cares a lot, please explain it under Java?C and Python, So many thanks.

    Read the article

  • Using locks inside a loop

    - by Xaqron
    // Member Variable private readonly object _syncLock = new object(); // Now inside a static method foreach (var lazyObject in plugins) { if ((string)lazyObject.Metadata["key"] = "something") { lock (_syncLock) { if (!lazyObject.IsValueCreated) lazyObject.value.DoSomething(); } return lazyObject.value; } } Here I need synchronized access per loop. There are many threads iterating this loop and based on the key they are looking for, a lazy instance is created and returned. lazyObject should not be created more that one time. Although Lazy class is for doing so and despite of the used lock, under high threading I have more than one instance created (I track this with a Interlocked.Increment on a volatile shared int and log it somewhere). The problem is I don't have access to definition of Lazy and MEF defines how the Lazy class create objects. My questions: 1) Why the lock doesn't work ? 2) Should I use an array of locks instead of one lock for performance improvement ?

    Read the article

  • Do I need to syncronize thread access to an int

    - by Martin Harris
    I've just written a method that is called by multiple threads simultaneously and I need to keep track of when all the threads have completed, the code uses this pattern: private void RunReport() { _reportsRunning++; try { //code to run the report } finally { _reportsRunning--; } } This is the only place within the code that _reportsRunning's value is changed, and the method takes about a second to run. Occasionally when I have more than six or so threads running reports together the final result for _reportsRunning can get down to -1, if I wrap the calls to _runningReports++ and _runningReports-- in a lock then the behaviour appears to be correct and consistant. So, to the question: When I was learning multithreading in C++ I was taught that you didn't need to synchronize calls to increment and decrement operations because they were always one assembly instruction and therefore it was impossible for the thread to be switched out mid-call. Was I taught correctly, and if so how come that doesn't hold true for C#?

    Read the article

  • how can we achieve second application read that file when first application not modifying it

    - by soField
    i have two application first application is bash second is java which one of them is periodically deleting and recreating a specific file (first) the other one is also periodically reading this file and process it in it's own logic (second) how can we achieve second application read that file when first application not modifying it my aim is to force second app read the file only when content of file fully written inside it how can achieve this goal ?

    Read the article

  • Multi-threading concept and lock in c#

    - by Neeraj
    I read about lock, though not understood nothing at all. My question is why do we use a un-used object and lock that and how this makes something thread-safe or how this helps in multi-threading ? Isn't there other way to make thread-safe code. public class test { private object Lock { get; set; } ... lock (this.Lock) { ... } ... } Sorry is my question is very stupid, but i don't understand, although i've used it many times.

    Read the article

  • Can I lock rows in a cursor if the cursor only returns a single count(*) row?

    - by RenderIn
    I would like to restrict users from inserting more than 3 records with color = 'Red' in my FOO table. My intentions are to A) retrieve the current count so that I can determine whether another record is allowed and B) prevent any other processes from inserting any Red records while this one is in process, hence the for update of. I'd like to do something like: cursor cur_cnt is select count(*) cnt from foo where foo.color = 'Red' for update of foo.id; Will this satisfy both my requirements or will it not lock only the rows in the count(*) who had foo.color = 'Red'?

    Read the article

  • Lock innoDB table temporarily

    - by Industrial
    Hi everyone, I make bigger inserts consisting of a couple of thousand rows in my current web app and I would like to make sure that no one can do anything but read the table, until the inserts have been done. What is the best way to do this while keeping the read availability open for normal, non-admin users? Thanks!

    Read the article

  • Thread-Safe lazy instantiating using MEF

    - by Xaqron
    // Member Variable private static readonly object _syncLock = new object(); // Now inside a static method foreach (var lazyObject in plugins) { if ((string)lazyObject.Metadata["key"] = "something") { lock (_syncLock) { // It seems the `IsValueCreated` is not up-to-date if (!lazyObject.IsValueCreated) lazyObject.value.DoSomething(); } return lazyObject.value; } } Here I need synchronized access per loop. There are many threads iterating this loop and based on the key they are looking for, a lazy instance is created and returned. lazyObject should not be created more that one time. Although Lazy class is for doing so and despite of the used lock, under high threading I have more than one instance created (I track this with a Interlocked.Increment on a volatile static int and log it somewhere). The problem is I don't have access to definition of Lazy and MEF defines how the Lazy class create objects. I should notice the CompositionContainer has a thread-safe option in constructor which is already used. My questions: 1) Why the lock doesn't work ? 2) Should I use an array of locks instead of one lock for performance improvement ?

    Read the article

  • What is better and why to use List as thread safe: BlockingCollection or ReaderWriterLockSlim or lock?

    - by theateist
    I have System.Collections.Generic.List _myList and many threads can read from it or add items to it simultaneously. From what I've read I should using 'BlockingCollection' so this will work. I also read about ReaderWriterLockSlim' and 'lock', but I don't figure out how to use them instead ofBlockingCollection`, so my question is can I do the same with: ReaderWriterLockSlim lock instead of using 'BlockingCollection'. If YES, can you please provide simple example and what pros and cons of using BlockingCollection, ReaderWriterLockSlim, lock?

    Read the article

  • detection of 'flush tables with read lock' in php

    - by theduke0
    I would like to know from my application if a myisam table can accept writes (i.e. not locked). If an exception is thrown, everything is fine as I can catch this and log the failed statement to a file. However, if a 'flush tables with read lock' command has been issued (possibly for backup), the query I send will pretty much hang out forever. If one table is locked at a time, insert delayed works well. But when this global lock is applied, my query just waits. The query I run is an insert statement. If this statement fails or hangs, user experience is degraded. I need a way to send the query to the server and forget about it (pretty much). Does anyone have any suggestions on how to deal with this? -set a query timeout? -run asyncronous request and allow for the lock to expire while application continues? -fork my php process? Please let me know if I can provide and clarification or details.

    Read the article

  • Best practice for avoiding locks on a heavily read table?

    - by Luiggi
    Hi, I have a big database (~4GB), with 2 large tables (~3M records) having ~180K SELECTs/hour, ~2k UPDATEs/hour and ~1k INSERTs+DELETEs/hour. What would be the best practice to guarantee no locks for the reading tasks while inserting/updating/deleting? I was thinking about using a NOLOCK hint, but there is so much discussed about this (is good, is bad, it depends) that I'm a bit lost. I must say I've tried this in a dev environment and I didn't find any problems, but I don't want to put it on production until I get some feedback... Thank you! Luiggi

    Read the article

  • VB.NET Program Locks Up with Internet Explorer Opened

    - by aaronsj
    I'm using Visual Studio 2008 and developing a VB.NET application. I'm having strange lockup problems with my program, but only when Internet explorer 8 is opened. When I cover my form with another window and then uncover it, I find that it has locked up. My program has no references to IE and the only thing it even has to do with IE is using Process.Start with a web address. My program works fine and exactly as it should, but only when IE is not opened. Does anyone know why a program would lock up only while IE is running? Edit: I've done some digging and I've found the offending thread in my program. I don't know what starts this thread or what it does, but when I kill it, my program no longer freezes. The thread is one of the CreateApplicationContext threads, here is the last few items in the stack trace of that thread. 6 ntkrnlpa.exe+0x897bc 7 ntdll.dll!KiFastSystemCallRet 8 mscorwrks.dll!LogHelp_TerminateOnAssert+0x61 9 mscorwrks.dll!DllUnregisterServerInternal+0x10523 10 mscorwrks.dll!DllUnregisterServerInternal+0x10542 11 mscorwrks.dll!StrongNameErrorInfo+0x34387 12 mscorwrks.dll!StrongNameErrorInfo+0x34815 13 mscorwrks.dll!CreateApplicationContext+0xbc35 14 KERNEL32.dll!GetModuleHandleA+0xdf Process explorer says my program is using no CPU nor throwing any exceptions while it is hung.

    Read the article

  • ActiveRecord and transactionsin between `before_save` and `save`

    - by JP
    I have some logic in before_save whereby (only) when some conditions are met I let the new row be created with special_number equal to the maximum special_number in the database + 1. (If the conditions aren't met then I do something different, so I can't use auto-increments) My worry is that two threads acting on this database at once might pick the same special_number if the second is executed while the first is saving. Is there way to lock the database between before_save and finishing the save, but only in some cases? I know all saves are sent in transactions, will this do the job for me? def before_save if things_are_just_right # -- Issue some kind of lock? # -- self.lock? I have no idea # Pick new special_number new_special = self.class.maximum('special_number') + 1 write_attribute('special_number',new_special) else # No need to lock in this case write_attribute('special_number',some_other_number) end end

    Read the article

  • What happens if you break out of a Lock() statement?

    - by cyclotis04
    I'm writing a program which listens to an incoming TcpClient and handles data when it arrives. The Listen() method is run on a separate thread within the component, so it needs to be threadsafe. If I break out of a do while loop while I'm within a lock() statement, will the lock be released? If not, how do I accomplish this? Thanks! (Any other advice on the subject of Asynchronous TCP Sockets is welcome as well.) private void Listen() { do { lock (_client) { if (!_client.Connected) break; lock (_stateLock) { if (!_listening) break; if (_client.GetStream().DataAvailable) HandleData(); } } Thread.Sleep(0); } while (true); }

    Read the article

  • How can I modify the application file of an application that is currently running (on Linux)?

    - by Hach-Que
    I have an application running called AppFS. This application has an ext2 filesystem just attached to the end of the file (it's positioned so that the application binary exists in a 1MB spacing area, followed by the ext2 data). Now I've got FUSE embedded in the program and I've managed to extract the filesystem out of the application data into a temporary file so that FUSE can mount / use it. The problem I have now is writing the temporary file back into the application file. I get "Text file busy" presumably because the application has locked itself and won't let writes occur. Is there a way I can force the file to become unlocked so I can write data to it? (It's important to note that I'm not changing the application binary area - just rewriting the ext2 component.) It needs to be unlocked without requiring root permissions (unlocked by the same user who started the application).

    Read the article

  • Real World Examples of read-write in concurrent software

    - by Richard Fabian
    I'm looking for real world examples of needing read and write access to the same value in concurrent systems. In my opinion, many semaphores or locks are present because there's no known alternative (to the implementer,) but do you know of any patterns where mutexes seem to be a requirement? In a way I'm asking for candidates for the standard set of HARD problems for concurrent software in the real world.

    Read the article

  • Copy a value based on criteria Salesforce

    - by Robert
    Hi all, On a Salesforce.com opportunity I have a number of custom fields that are potential options that the end client will eventually select. Option 1 (Desc Field) Option 1 (Value) Option 2 (Desc Field) Option 2 (Value) Option 3 (Desc Field) Option 3 (Value) At a future point the user will ultimately choose one of the options as the preferred option. What I want is then the value for the chosen option to be stored in another field without the user having to enter it again. A “nice to have” would also be that all 3 option descriptions, values and selected value are locked once this is done. Any ideas?

    Read the article

  • How to create "lock" (stop updating of cells) in Excel?

    - by Oozi
    My question is pretty simple, but one to which I can't really find a solution myself. I use Excel quite frequently, but rarely the fancy stuff. Anyway, to the point: How do I create a dropmenu that will lock certain cells, rows or columns? (by lock I mean unable to change via hand and stops updating itself). Example: A1 = 5 B1 = A1 * 100 Can I "lock" the B1-cell, so that changing A1 will have no effect on B1 (Will remain at value 500)? I would preferably want to be able to "unlock" the cell as well, instead of simply making function into value. Is this possible? Thanks in advance!

    Read the article

< Previous Page | 9 10 11 12 13 14 15 16 17 18 19 20  | Next Page >