Возможно, стоит пояснить разницу между синхронизацией из thread/process-safe и синхронизацией с помощью Lock🤔
Наша задача — заставить разные процессы и потоки обращаться к базе данных (или любым другим ресурсам) последовательно. Чтобы не случилось так называемого race condition, то есть состояние гонки. Это когда разные потоки или процессы пытаются одновременно что-то сделать с одним и тем же ресурсом.
В этом случае нам нужна какая-то логика ограничения. Пока один процесс не завершил своё действие, другие не могут получить доступ к ресурсу.
Так вот, thread-safe и process-safe означает что отдельно взятые операции записи в БД гарантированно будут последовательны. Запросы из разных процессов или потоков выстроятся в очередь и не будут мешать друг другу. Лучше всего когда этот блок реализован на уровне БД в виде атомарных операций или ещё как-то.
Но зачем нам тогда еще дополнительный Lock?
Этот способ синхронизации используется когда процесс никак не укладывается в одно действие и должен сделать множество операций прежде чем дать доступ следующему. В этом случае процесс ставит некий глобальный Lock на ресурс и никто другой, даже получив законное право на доступ, не может ничего сделать. Все ждут пока этот Lock не будет снят.
Это решается на уровне приложения и правильность реализации полностью в вашей ответственности. Например, если забыли разблокировать или сделали перекрёстный Lock (Deadlock как на картинке), то всё зависнет в бесконечном ожидании.
#basic
🇷🇺🇺🇳 Foreign Minister Sergey Lavrov & Secretary-General of the United Nations António Guterres meet on the sidelines of the UN General Assembly's 77th Session's High-Level Week.
#UNGA77
#UNCharterIsOurRules
🇺🇳 The High-Level Week of the 77th Session of the UN General Assembly has come to an end.
#Day4 main highlight 👉 FM Sergey Lavrov's Remarks at the General Debate.
The Minister touched upon the most topical issues on the international agenda.
📹 The essence of the speech in 1 minute.
#UNGA77
🇺🇳 The UN HQ is where it's at! The High-Level Week of the 77th UNGA Session continues as does our coverage!
🎥 On #Day3 (Sept 23), the Russian delegation led by Sergey Lavrov kept busy. Sorry to disappoint certain Western colleagues, but no "isolation" in sight:
• Talks with President of Serbia and President of Guinea-Bisau
• Talks with Chairman of the Transitional Sovereignty Council of Sudan
• Meetings and talks with Foreign Ministers of Serbia, Мexico, Ethiopia, Nicaragua, Laos, Jordan, Syria, Eritrea, Cuba, Equatorial Guinea, Mali, the UAE!
• Russia – Gulf Cooperation Council Ministerial
Stay tuned and follow our updates from New York!
#UNGA77
🛑#LIVE: Foreign Minister Sergey #Lavrov gives speech at the UNSC meeting on Ukraine
🔗https://www.ruptly.tv/en/events/202209221400-LIVE11963-UN-Security-Council-holds-high-level-debate-on-Ukraine
🔗https://mid.ru/en/press_service/video
🔗https://media.un.org/en/webtv
#UNGA77
Off we go! 🇺🇳
#Day1 highlights!
On September 21, Sergey Lavrov arrived to the United Nations Headquarters in New York to participate in the 77th Session of the UN General Assembly (#UNGA77).
🤝 On the first day the Minister's working schedule was packed:
• Working meeting of CSTO Foreign Ministers
• Talks with President of the CAR Faustin-Archange Touadéra and President of Switzerland Ignazio Cassis
• Meetings with Ministers of Foreign Affairs of China, Brazil, Bolivia and Egypt
• Meetings with President of the ICRC Peter Maurer and IAEA Director General Rafael Mariano Grossi
• Meeting in the Astana Format
• The signing of The Inter-Ministerial Consultations Plan between the Foreign Ministries of Russia and Venezuela
• Talks with President of the 77th UNGA session Csaba Kőrösi
Stay tuned for #Day2. Coming next!
Off we go! 🇺🇳
#Day1 highlights!
On September 21, Sergey Lavrov arrived to the United Nations Headquarters in New York to participate in the 77th Session of the UN General Assembly (#UNGA77).
🤝 On the first day the Minister's working schedule was packed:
• Working meeting of CSTO Foreign Ministers
• Talks with President of the CAR Faustin-Archange Touadéra and President of Switzerland Ignazio Cassis
• Meetings with Ministers of Foreign Affairs of China, Brazil, Bolivia and Egypt
• Meetings with President of the ICRC Peter Maurer and IAEA Director General Rafael Mariano Grossi
• Meeting in the Astana Format
• The signing of The Inter-Ministerial Consultations Plan between the Foreign Ministries of Russia and Venezuela
• Talks with President of the 77th UNGA session Csaba Kőrösi
Stay tuned for #Day2. Coming next!