acid

Transactionally writing files in Node.js

与世无争的帅哥 提交于 2019-12-05 03:44:16
I have a Node.js application that stores some configuration data in a file. If you change some settings, the configuration file is written to disk. At the moment, I am using a simple fs.writeFile . Now my question is: What happens when Node.js crashes while the file is being written? Is there the chance to have a corrupt file on disk? Or does Node.js guarantee that the file is written in an atomic way, so that either the old or the new version is valid? If not, how could I implement such a guarantee? Are there any modules for this? What happens when Node.js crashes while the file is being

Row level atomic MERGE REPLACE in BigQuery

独自空忆成欢 提交于 2019-12-04 19:08:53
For my use case I'm working with data identifiable by unique key at the source exploded into n (non deterministic) number of target entries loaded into BigQuery tables for analytic purposes. Building this ETL to use Mongo recent Change Stream feature I would like to drop all entries in BigQuery and then load the new entries atomically. Exploring BigQuery DML I see a MERGE operation is supported, but only WHEN MATCHED THEN DELETE or WHEN MATCHED THEN UPDATE is possible. I'm interested in a WHEN MATCHED THEN DELETE, AND FOLLOW BY AN INSERT operation. How would I implement such ETL in BigQuery

[转帖]关于分布式

强颜欢笑 提交于 2019-12-04 16:25:12
https://www.cnblogs.com/wupeixuan/p/9302496.html 第一章主要讲的是分布式架构,主要包含以下内容: 集中式的特点 分布式的特点 分布式环境的各种问题 ACID 分布式事务 CAP和BASE理论 1 | 1 集中式与分布式的特点 集中式的特点:部署结构简单(因为基于底层性能卓越的大型主机,不需考虑对服务多个节点的部署,也就不用考虑多个节点之间分布式协调问题) 分布式的特点: 分布性 对等性 并发性 缺乏全局时钟 故障总是会发生 1 | 2 分布式环境的各种问题 分布式环境的各种问题: 通信异常:主要是因为网络本身的不可靠性 网络分区:当网络发生异常时,导致部分节点之间的网络延时不断增大,最终导致部分节点可以通信,而另一部分节点不能。 三态(成功、失败与超时) 节点故障:组成分布式系统的服务器节点出现宕机或“僵死”现象 1 | 3 ACID与分布式事务 事务是由一系列对系统中数据进行访问与更新的操作所组成的一个程序执行逻辑单元,狭义上的事务特指数据库事务。 事务有四个特性,分别是原子性(Atomicity)、一致性(Consistency)、隔离性(Isolation)和持久性(Durability),简称为事务的ACID特性。 原子性(Atomicity):必须是一个原子的操作序列单元,只允许出现两种状态之一(全部成功执行,全部不执行)。

How To Implement ACID Transactions in Loopback

最后都变了- 提交于 2019-12-04 12:05:29
We've been trying to implement ACID transactions in Loopback without success. The only examples in the documentation use the 'create' method.We've tried completely overriding the events as well as multiple variations of Operation Hooks. We have only been able to get the create example to work. Core Requirement : We need to be able to start a transaction in the create and update methods for a specific model and then update multiple tables in the transaction (either using Loopback's ORM functions or directly with SQL) with the ability to commit or rollback based on business rules. For example ,

Does the CAP theorem imply that ACID is not possible for distributed databases?

你说的曾经没有我的故事 提交于 2019-12-03 07:52:43
问题 There are NoSQL ACID (distributed) databases, despite CAP theorem. How this is possible? What's the relation between CAP theorem and (possible/not possible of) being ACID? Is impossible for a distributed computer system to simultaneously provide consistency, availability and partition tolerance. 回答1: CAP theorem is actually a bit misleading. The fact you can have a CA design is nonsense because when a partition occurs you necessarily have a problem regarding consistency (data synchronization

Write Skew anomaly in Oracle and PostgreSQL does not rollback transaction

六月ゝ 毕业季﹏ 提交于 2019-12-03 05:20:18
问题 I noticed the following occurrence in both Oracle and PostgreSQL. Considering we have the following database schema: create table post ( id int8 not null, title varchar(255), version int4 not null, primary key (id)); create table post_comment ( id int8 not null, review varchar(255), version int4 not null, post_id int8, primary key (id)); alter table post_comment add constraint FKna4y825fdc5hw8aow65ijexm0 foreign key (post_id) references post; With the following data: insert into post (title,

MySQL InnoDB: Difference Between `FOR UPDATE` and `LOCK IN SHARE MODE`

我与影子孤独终老i 提交于 2019-12-03 03:51:44
问题 What is the exact difference between the two locking read clauses: SELECT ... FOR UPDATE and SELECT ... LOCK IN SHARE MODE And why would you need to use one over the other? 回答1: I have been trying to understand the difference between the two. I'll document what I have found in hopes it'll be useful to the next person. Both LOCK IN SHARE MODE and FOR UPDATE ensure no other transaction can update the rows that are selected. The difference between the two is in how they treat locks while reading

Are disk sector writes atomic?

孤人 提交于 2019-12-03 00:33:35
问题 Clarified Question: When the OS sends the command to write a sector to disk is it atomic? i.e. Write of new data succeeds fully or old data is left intact should the power fail immediately following the write command. I don't care about what happens in multiple sector writes - torn pages are acceptable. Old Question: Say you have old data X on disk, you write new data Y over it, and a tree falls on the power line during that write. With no fancy UPS or battery backed disk controller, you can

事务的特性(ACID)

匿名 (未验证) 提交于 2019-12-03 00:22:01
一、ACID简介 二、什么是脏读、不可重复读、虚读 多个线程开启各自事务操作数据库中数据时,数据库系统要负责隔离操作,以保证各个线程在获取数据时的准确性。 如果不考虑隔离性,可能会引发如下问题: 1 指一个事务读取了另外一个事务未提交的数据。 100 sql 1.update account set money=money+100 while name= b ; 2.update account set money=money-100 while name= a ; 1 sql 2 (A ) 100 A B B 100 2 在一个事务内读取表中的某一行数据,多次读取结果不同。 update A A 200 A 100 A 300 和脏读的区别是,脏读是读取前一事务未提交的脏数据,不可重复读是重新读取了前一事务已提交的数据。 很多人认为这种情况就对了,无须困惑,当然是后面的为准。我们可以考虑这样一种情况,比如银行程序需要将查询结果分别输出到电脑屏幕和写到文件中,结果在一个事务中针对输出的目的地,进行的两次查询不一致,导致文件和屏幕中的结果不一致,银行工作人员就不知道以哪个为准了。 3 ( ) 是指在一个事务内读取到了别的事务插入的数据,导致前后读取不一致。 insert 100 account 500 600 三、种事务隔离级别 1 ( ) (2)查看与设置当前的事物级别:

Does the CAP theorem imply that ACID is not possible for distributed databases?

ぃ、小莉子 提交于 2019-12-02 21:19:48
There are NoSQL ACID (distributed) databases , despite CAP theorem. How this is possible? What's the relation between CAP theorem and (possible/not possible of) being ACID? Is impossible for a distributed computer system to simultaneously provide consistency, availability and partition tolerance. CAP theorem is actually a bit misleading. The fact you can have a CA design is nonsense because when a partition occurs you necessarily have a problem regarding consistency (data synchronization issue for example) or availability (latency). That's why there is a more accurate theorem stating that :