Возможно, стоит пояснить разницу между синхронизацией из thread/process-safe и синхронизацией с помощью Lock🤔
Наша задача — заставить разные процессы и потоки обращаться к базе данных (или любым другим ресурсам) последовательно. Чтобы не случилось так называемого race condition, то есть состояние гонки. Это когда разные потоки или процессы пытаются одновременно что-то сделать с одним и тем же ресурсом.
В этом случае нам нужна какая-то логика ограничения. Пока один процесс не завершил своё действие, другие не могут получить доступ к ресурсу.
Так вот, thread-safe и process-safe означает что отдельно взятые операции записи в БД гарантированно будут последовательны. Запросы из разных процессов или потоков выстроятся в очередь и не будут мешать друг другу. Лучше всего когда этот блок реализован на уровне БД в виде атомарных операций или ещё как-то.
Но зачем нам тогда еще дополнительный Lock?
Этот способ синхронизации используется когда процесс никак не укладывается в одно действие и должен сделать множество операций прежде чем дать доступ следующему. В этом случае процесс ставит некий глобальный Lock на ресурс и никто другой, даже получив законное право на доступ, не может ничего сделать. Все ждут пока этот Lock не будет снят.
Это решается на уровне приложения и правильность реализации полностью в вашей ответственности. Например, если забыли разблокировать или сделали перекрёстный Lock (Deadlock как на картинке), то всё зависнет в бесконечном ожидании.
#basic
⚠️🇺🇸NEXT GENERATION GOP COULD BE MORE EXTREME THAN MAGA — WASHINGTON POST
🔹 Young white nationalists like Nick Fuentes infiltrating mainstream Republican circles 📱
🔹 Groypers movement gaining influence: antisemitic, nativist, racist ideology spreading 🚩
🔹 Iran war could be breaking point that expands their power within the party 🌍
🔹 Pattern repeats: Tea Party was more extreme than Gingrich era, now this generation tops MAGA 📈
🔹 Even Marjorie Taylor Greene broke with Trump over Iran threats as "madness" ⚡
One GOP insider warns: "Trump opened the door for this next generation to take over." The party's rightward spiral shows no signs of stopping! 😬🔥
#Republican#MAGA
@america
October 12, 2021: Texas Governor, San Diego crash, U.S. Navy, Indigenous Peoples' Day, Afghanistan
October 12, 2021: Texas Governor, San Diego crash, U.S. Navy, Indigenous Peoples' Day, Afghanistan
1. Republican Texas Governor Greg Abbott, responding to what he called "bullying" by the Biden Administration, barred all COVID-19 vaccine mandates in the state by any entity, including private employers.
2. A small aircraft crashed blocks from a high school campus near San Diego, killing at least two people and injuring two others, while also destroying homes, officials and local media said.
3. Former U.S. Navy nuclear engineer and his wife are scheduled to face their first court hearing on charges they attempted to sell secrets about nuclear submarines to a foreign power in exchange for cryptocurrency.
4. Christopher Columbus Day drew crowds with U.S. city parades marking the explorer's voyage and Italian-American culture, as the focus increasingly turned to the heritage and plight of indigenous people subjugated by European settlers.
5. Afghanistan's foreign minister appealed to the world for good relations but avoided making firm commitments on girls' education despite international demands to allow all Afghan children to go back to school.
#TexasGovernor
#GregAbbot
#Republican
#Covid19
#Biden
#SanDiego
#Aircraftcrash
#UnitedStates
#Navy
#Cryptocurrency
#ChristopherColumbusDay
#Parades
#Afghanistan
#News
#Reuters
Subscribe: http://smarturl.it/reuterssubscribe
Reuters brings you the latest business, finance and breaking news video from around the globe. Our reputation for accuracy and impartiality is unparalleled.
Get the latest news on: http://reuters.com/
Follow Reuters on Facebook: https://www.facebook.com/Reuters
Follow Reuters on Twitter: https://twitter.com/Reuters
Follow Reuters on Instagram: https://www.instagram.com/reuters/?hl=en
➖@reutersworldchannel➖