That is all dependent on the program, but the simplest scenario is by an API with two requests at the same time. But it may also be like if you scan for new files, and use inotify, then you may also have a scanning loop as a fallback. Then the scan and inotify may trigger at almost the same time, so if that then results in a db create or insert you can get in to this problem. So, there are multiple ways to get in to trouble, and life always find new ways 😀
snaggen
You are free to see this as an ad, but as Rust is targeting safety critical programming in general, I find it interesting to follow certification efforts like this to make rust available for really safety critical use cases. Now, the Ferrocene project is contributing back, but that fact or the license does not really affect the relevance for this community.
Well, of course you should stick to rustc if you don't need the certification. I get the impression you mix up thing and the purpose of a certified compiler.
Ferrous Systems is working on certifying a specific version of rustc, and hence make it possible to use rust for projects where such certification is required. And certification is required for things like programming medical equipment. If you are hooked in to life support, it is good if the compiler did the thing it was supposed to do.... a crash in such programs can be fatal in a very literal way.
Also, notice that they try to do this without forking and by contributing upstream.
As I still run in to glibc version issues a little now and then (admittedly not very often, thankss to containers), I hope to see rust getting rid of libc one day. But I don't expect that in the near future, because as the author mentions, libc is very mature, so replacing it must be done with a lot of caution. But this really looks like a step in the right direction.
I think this is was a great read, since it shows a few important things
- Coming to rust from C is not trivial, you are required to learn a few new concepts (or not really new, but implicit in most languages, formalized in rust).
- When coming from C and you understand the basic concepts, it is easier to learn rust than from many other languages, since you understand what is going on under the hood. Dangling pointers, and use after free aso, are known concepts. C/C++ programmers don't have to fear rust.
- The rust book is a great source of information.
So, a loop it is....
That will always be prune to race conditions, where you check if someting exists (then some other thread creates it) and then you try to create it. You should always try to create first, then if it fails due to it already existing, fetch it. That is a good general rule for anything from hashmaps to databases.
I have never used sea-orm, but I wonder if .on_conflict
could be used to simplify the code above?
No ads disguised as search results. Actually, no ads at all. Great search results. Lenses.
Also, there is a solution for incognito mode. And ad supported, in practice means tracked by advertisers, and hence you are the product.
All these services turning into shit, are the services without a viable business model to begin with. What I find interesting is that it is obviously possible to become leading in a field, just by burning investors money.
The reason might be, that you must think a bit different from C++ so it might be a little bit tricky to do the switch. Thouigh, if you know C++ the ownership and stuff should be a bit easier to understand since you probably can figure out what is going on. The reason I learned Rust in the first place was because I had to use C libraries, and I knew rust had good support for that. But, unfortunately I cannot assist you with alternatives to rust, since I stopped looking after I learned rust. 😄
It might be interesting to watch the Jackie Chan episode of Every Frame is a Painting, for an analysis of the difference between Hollywood and Hong Kong. This will explain why Jackie Chan is so much better in his Hong Kong movies.
https://m.youtube.com/watch?v=Z1PCtIaM_GQ