NoSQL ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ์œ„ํ•œ ๋ถ„์‚ฐํ˜• ACID ํŠธ๋žœ์žญ์…˜

๊ณ ๊ฐ€์šฉ์„ฑ์„ ๊ฐ–์ถ˜ ๋Œ€๊ทœ๋ชจ SQL์˜ ACID

Couchbase SQL++์˜ ACID ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ํŠธ๋žœ์žญ์…˜

Couchbase๋Š” ์„ฑ๋Šฅ๊ณผ ๊ณ ๊ฐ€์šฉ์„ฑ์˜ ์ €ํ•˜ ์—†์ด ๋Œ€๊ทœ๋ชจ์˜ ๋ถ„์‚ฐ๋œ ๋‹ค์ค‘ ๋ฌธ์„œ ACID ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ํŠธ๋žœ์žญ์…˜์„ ์ง€์›ํ•ฉ๋‹ˆ๋‹ค. ๊ด€๊ณ„ํ˜• ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ Couchbase๋กœ ๋งˆ์ด๊ทธ๋ ˆ์ด์…˜ํ•˜๊ณ  ํ’๋ถ€ํ•œ SQL ์ง€์›์„ ํ™œ์šฉํ•˜๋ฉด์„œ ACID ๊ทœ์ •์„ ์ค€์ˆ˜ํ•˜์„ธ์š”.

Analytics ecosystem diagra

ACID๋ž€ ๋ฌด์—‡์ธ๊ฐ€์š”?

๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์—์„œ ACID๋Š” ํŠธ๋žœ์žญ์…˜์„ ์ผ๊ด€์„ฑ ์žˆ๊ณ  ์•ˆ์ „ํ•˜๋ฉฐ ์•ˆ์ •์ ์œผ๋กœ ์ฒ˜๋ฆฌํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์„ค๋ช…ํ•˜๋Š” ์•ฝ์–ด์ž…๋‹ˆ๋‹ค:

A ์›์ž์„ฑ ๋ชจ๋“  ๋ฌธ์„œ๋ฅผ ์—…๋ฐ์ดํŠธํ•  ์ˆ˜ ์žˆ๋„๋ก ๋ณด์žฅํ•ฉ๋‹ˆ๋‹ค.
C ์ผ๊ด€์„ฑ ๋ณต์ œ๋ณธ, ์ธ๋ฑ์Šค ๋ฐ XDCR์˜ ์ผ๊ด€์„ฑ์ด ์ž๋™์œผ๋กœ ์œ ์ง€๋ฉ๋‹ˆ๋‹ค.
I ๊ฒฉ๋ฆฌ ๋™์‹œ ๋…์ž๋ฅผ ์œ„ํ•œ ์ฝ๊ธฐ ์ปค๋ฐ‹ ๊ฒฉ๋ฆฌ.
D ๋‚ด๊ตฌ์„ฑ ๋‚ด๊ตฌ์„ฑ ์ˆ˜์ค€์„ ์กฐ์ •ํ•  ์ˆ˜ ์žˆ๋Š” ์žฅ์•  ์‹œ ๋ฐ์ดํ„ฐ ๋ณดํ˜ธ.

ํŠธ๋žœ์žญ์…˜ ์ฝ”๋“œ ์ƒ˜ํ”Œ

๋‹ค์Œ์€ ์ผ๋ฐ˜์ ์ธ ๊ฑฐ๋ž˜ ์‹œ๋‚˜๋ฆฌ์˜ค์— ๋Œ€ํ•œ ์„ธ ๊ฐ€์ง€ ์ฝ”๋“œ ์ƒ˜ํ”Œ์ž…๋‹ˆ๋‹ค. ์ฒซ ๋ฒˆ์งธ๋Š” ๋‘ ๊ณ„์ •์ด ๋ชจ๋‘ ์ˆ˜์ •๋˜๊ฑฐ๋‚˜ ์ˆ˜์ •๋˜์ง€ ์•Š๋„๋ก ํ•˜๋Š” ์ง๋ถˆ/์‹ ์šฉ ๊ฑฐ๋ž˜์ž…๋‹ˆ๋‹ค. ๋‘ ๋ฒˆ์งธ๋Š” SQL++๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ถ€์„œ์˜ ๋ชจ๋“  ์ง์›์„ ์ผ๊ด„ ์—…๋ฐ์ดํŠธํ•˜์—ฌ ๋ชจ๋“  ์ง์›์ด ์—…๋ฐ์ดํŠธ๋˜์—ˆ๋Š”์ง€ ๋˜๋Š” ์•„๋ฌด๋„ ์—…๋ฐ์ดํŠธ๋˜์ง€ ์•Š์•˜๋Š”์ง€ ํ™•์ธํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.

 START TRANSACTION;
UPDATE customer SET balance = balance + 100 WHERE cid = 4872;
SELECT cid, name, balance  from customer;
SAVEPOINT s1;
UPDATE customer SET balance = balance โ€“ 100 WHERE cid = 1924;
SELECT cid, name, balance from customer;
ROLLBACK WORK TO SAVEPOINT s1;
SELECT cid, name, balance from customer;
COMMIT ;
 // Transfer money from Bethโ€™s account to Andyโ€™s account

transactions.run((txnctx) -> {
var andy = txnctx.get(collection, "Andy");
var andyContent = andy.contentAsObject();
int andyBalance = andyContent.getInt("account_balance");
var beth = txnctx.get(collection, "Beth");
var bethContent = beth.contentAsObject();
int bethBalance = bethContent.getInt("account_balance");

	if (bethBalance > transferAmount) {
		andyContent.put("account_balance", andyBalance + transferAmount);
		txnctx.replace(andy, andyContent);
bethContent.put("account_balance", bethBalance - transferAmount);
txnctx.replace(beth, bethContent);
}
else throw new InsufficientFunds();  
txnctx.commit();
 });
 // Bulk update salaries of all employees in a department
transactions.run((ctx) -> {

    var auditLine = JsonObject.create().put("content", "Update on 4/20/2020");
    ctx.insert(auditCollection, "Dept10", auditLine);
    ctx.query("UPDATE employees 
               SET salary = salary * 1.1  
               WHERE dept = 10 AND salary < 50000");
    ctx.query("UPDATE department 
               SET status = 'updated'
               WHERE dept = 10");
   
    txnctx.commit();  
});

๋†€๋ผ์šด ๊ณ ๊ฐ ๊ฒฝํ—˜์„ ๋งŒ๋“ค ์ค€๋น„๊ฐ€ ๋˜์…จ๋‚˜์š”?

Couchbase๋ฅผ ์‹œ์ž‘ํ•˜๋Š” ๊ฐ€์žฅ ์‰ฝ๊ณ  ๋น ๋ฅธ ๋ฐฉ๋ฒ•