race-condition

Django: IntegrityError during Many To Many add()

蹲街弑〆低调 提交于 2019-12-08 14:56:29
问题 We run into a known issue in django: IntegrityError during Many To Many add() There is a race condition if several processes/requests try to add the same row to a ManyToManyRelation. How to work around this? Envionment: Django 1.9 Linux Server Postgres 9.3 (An update could be made, if necessary) Details How to reproduce it: my_user.groups.add(foo_group) Above fails if two requests try to execute this code at once. Here is the database table and the failing constraint: myapp_egs_d=> \d auth

ASP.NET Resource Manager RaceCondition in Multilingual Application

点点圈 提交于 2019-12-08 06:28:16
问题 We're using resource manager to load resources based on Thread UI culture in an ASP.NET MVC 4 application.We set thread culture as below: protected void Application_AcquireRequestState(object sender, EventArgs e) { var lang = HttpContext.Current.Request.RequestContext.RouteData.Values["lang"]; var ci = new CultureInfo(lang); var culture = CultureInfo.CreateSpecificCulture(ci.Name); culture.DateTimeFormat.AMDesignator = "AM"; culture.DateTimeFormat.PMDesignator = "PM"; Thread.CurrentThread

Race condition with waitgroup and unbuffered channel

心已入冬 提交于 2019-12-08 05:11:27
问题 After getting (the right) solution to my initial problem in this post Understanding golang channels: deadlock, I have come up with a slightly different solution (which in my opinion reads better: // Binary histogram counts the occurences of each word. package main import ( "fmt" "strings" "sync" ) var data = []string{ "The yellow fish swims slowly in the water", "The brown dog barks loudly after a drink ...", "The dark bird bird of prey lands on a small ...", } func main() { histogram := make

Race condition firing events in AS3

∥☆過路亽.° 提交于 2019-12-08 04:55:46
问题 I have some troubles firing and removing events in the right chronicle order. The code below gives the following output: save poster into db, and dispatch event calling service, dispatch event removed = false calling service, dispatch event removed = false calling service, dispatch event removed = true save poster into db, and dispatch event save poster into db, and dispatch event of course this should be more something like: save poster into db, and dispatch event calling service, dispatch

Multi-threading a merge sorting algorithm

岁酱吖の 提交于 2019-12-08 04:30:21
问题 I have a class that does some recursive merge sorting on a generic List, as long as the element implements Comparable. I'm trying to make the code multi-threaded to improve performance, and to do this, I have a static variable maxThreads which keeps the number of threads I create from not exploding, and I have a static variable currentThreads that keeps track of the number of threads I currently have running. There seems to be a race condition on my currentThreads variable, but I haven't been

Why is the behavior of setTimeout(0) and setImmediate() undefined when used in the main module ?

可紊 提交于 2019-12-07 06:54:52
问题 Take the following code taken from the nodejs event loop documentation : // timeout_vs_immediate.js setTimeout(() => { console.log('timeout'); }, 0); setImmediate(() => { console.log('immediate'); }); According to the documentation : For example, if we run the following script which is not within an I/O cycle (i.e. the main module), the order in which the two timers are executed is non-deterministic, as it is bound by the performance of the process. Why is the above statement true ? Is it

Django session race condition?

萝らか妹 提交于 2019-12-07 04:02:39
问题 Summary: is there a race condition in Django sessions, and how do I prevent it? I have an interesting problem with Django sessions which I think involves a race condition due to simultaneous requests by the same user. It has occured in a script for uploading several files at the same time, being tested on localhost. I think this makes simultaneous requests from the same user quite likely (low response times due to localhost, long requests due to file uploads). It's still possible for normal

c++ should condition variable be notified under lock

孤街醉人 提交于 2019-12-07 01:50:09
问题 I found the following example for condition variable on www.cppreference.com, http://en.cppreference.com/w/cpp/thread/condition_variable. The call to cv.notify_one() is placed outside the lock. My question is if the call should be made while holding the lock to guarantee that waiting threads are in fact in waiting state and will receive the notify signal. #include <iostream> #include <string> #include <thread> #include <mutex> #include <condition_variable> std::mutex m; std::condition

Intermittent ClassCastException from ElementNSImpl to own type during unmarshalling

青春壹個敷衍的年華 提交于 2019-12-07 01:02:37
问题 We are experiencing an exceedingly hard to track down issue where we are seeing ClassCastExceptions sometimes when trying to iterate over a list of unmarshalled objects. The important bit is sometimes , after a reboot the particular code works fine. This seems to point in the direction of concurrency/timing/race condition. I can confirm that neither the JAXBContext, nor the marshallers and unmarshallers are being used concurrently. We've gone as far as serializing access to them through

ASP.NET Resource Manager RaceCondition in Multilingual Application

这一生的挚爱 提交于 2019-12-06 15:51:01
We're using resource manager to load resources based on Thread UI culture in an ASP.NET MVC 4 application.We set thread culture as below: protected void Application_AcquireRequestState(object sender, EventArgs e) { var lang = HttpContext.Current.Request.RequestContext.RouteData.Values["lang"]; var ci = new CultureInfo(lang); var culture = CultureInfo.CreateSpecificCulture(ci.Name); culture.DateTimeFormat.AMDesignator = "AM"; culture.DateTimeFormat.PMDesignator = "PM"; Thread.CurrentThread.CurrentUICulture = culture; Thread.CurrentThread.CurrentCulture = culture; } We think there is a