Возможно, стоит пояснить разницу между синхронизацией из thread/process-safe и синхронизацией с помощью Lock🤔
Наша задача — заставить разные процессы и потоки обращаться к базе данных (или любым другим ресурсам) последовательно. Чтобы не случилось так называемого race condition, то есть состояние гонки. Это когда разные потоки или процессы пытаются одновременно что-то сделать с одним и тем же ресурсом.
В этом случае нам нужна какая-то логика ограничения. Пока один процесс не завершил своё действие, другие не могут получить доступ к ресурсу.
Так вот, thread-safe и process-safe означает что отдельно взятые операции записи в БД гарантированно будут последовательны. Запросы из разных процессов или потоков выстроятся в очередь и не будут мешать друг другу. Лучше всего когда этот блок реализован на уровне БД в виде атомарных операций или ещё как-то.
Но зачем нам тогда еще дополнительный Lock?
Этот способ синхронизации используется когда процесс никак не укладывается в одно действие и должен сделать множество операций прежде чем дать доступ следующему. В этом случае процесс ставит некий глобальный Lock на ресурс и никто другой, даже получив законное право на доступ, не может ничего сделать. Все ждут пока этот Lock не будет снят.
Это решается на уровне приложения и правильность реализации полностью в вашей ответственности. Например, если забыли разблокировать или сделали перекрёстный Lock (Deadlock как на картинке), то всё зависнет в бесконечном ожидании.
#basic
Shipping disruptions strand 8 million kg of #Kenyan tea in #Mombasa as #US-#Israel war with #Iran hits exports
Disruptions to global shipping routes linked to the ongoing war between the United States, Israel, and Iran have left nearly eight million kilograms of tea stranded in warehouses in Mombasa, threatening export earnings and farmer incomes, according to the East Africa Tea Traders Association.
George Omuga, managing director of the association that runs the Mombasa tea auction, told Reuters that losses have been accumulating at roughly $8 million per week since 01 March.
“The current conflict in the Middle East has had a direct impact, a negative impact on this auction,” Omuga said, noting that no tea shipments were currently leaving for Middle Eastern markets, which account for 20–25% of Kenya’s tea exports.
https://x.com/addisstandard/status/2039378986518626404?s=20
News: #Somaliland's #Israel deal could put #Berbera port at risk
#Somaliland says its recognition by Israel could be a boon for its Berbera port. But with missiles flying across the region, it could also be a target.
Berbera port on the Gulf of Aden has been transformed by the #UAE firm #DP_World over the past decade into a state-of-the-art facility on one of the world's busiest trade routes.
Berbera still handles far fewer containers than nearby #Djibouti or #Mombasa, but port traffic was up 30 percent from 2023 to 2025, and recent diplomatic moves could lead to much more.
A deal under negotiation with #Ethiopia, a landlocked neighbour with more than 130 million inhabitants, could see traffic rise by another 80 percent, said port authority director Ali Diriye Ahmed.
Ethiopia did not respond to queries on the subject.
But an alliance with Israel also brings risks, particularly as the US-Israeli attacks on Iran this weekend increase the threat of ........
Read more: https://addisstandard.com/?p=55487