SpringBoot AOP + Redis delayed double deletion to ensure data consistency

SpringBoot AOP + Redis Delayed double deletion ensures data consistency 1. Business scenario 1.1 Problems When using Redis as a cache, there will be inconsistencies between the data in Redis and the database data. In the subsequent query process, it will take a long time to check Redis first, thus The occurrence of queried data […]

Asynchronously process CompletableFuture data operations and use DefaultTransactionDefinition to ensure transaction consistency

package *.utils; import lombok.extern.slf4j.Slf4j; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.TransactionStatus; import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicBoolean; @Slf4j public class ThreadTransationUtil { private final PlatformTransactionManager transactionManager; public ThreadTransationUtil(PlatformTransactionManager transactionManager) { this.transactionManager = transactionManager; } public void threadBlocking(CountDownLatch latch, TransactionStatus status, AtomicBoolean isException) throws InterruptedException { latch.countDown(); log.info(“Start hovering, remaining count: {}”, latch.getCount()); latch.await(); if(isException.get()){ log.info(“Start rollback”); transactionManager.rollback(status); }else{ log.info(“Start submission:{}”,status); […]

Solve the problem of inconsistency between pandas.core.frame.DataFrame format data and numpy.ndarray format data resulting in inoperability

Table of Contents Solve the problem of inconsistency between pandas.core.frame.DataFrame format data and numpy.ndarray format data resulting in inoperability Problem Description Solution Summarize ndarray of numpy library What is ndarray? Features of ndarray Create ndarray ndrray properties and methods Indexing and slicing of ndrray Solve the problem of inconsistency between pandas.core.frame.DataFrame format data and numpy.ndarray […]

SpringBoot SerializationUtils cloning (deserialization) class loader inconsistency problem (ClassCastException)

Problem analysis When using the org.apache.commons.lang.SerializationUtils.clone method in SpringBoot, it was found that a type inconsistency error occurred when the cloned class was forced to the corresponding class. After inspection, it was found that two seemingly identical Class loaders for classes are inconsistent Scene Error message java.lang.ClassCastException: com.tianqiauto.tis.pc.dingdanyupai.po.PrePoint cannot be cast to com.tianqiauto.tis.pc.dingdanyupai.po.PrePoint Detection information […]

How to construct a strongly consistent system? Understand the principles of 2PC and TCC modes in data consistency and how to do it (with pictures)

Background First of all, when reading this article, you should first understand what a transaction is and what a distributed transaction is. Let me give 2 examples here. There are two typical scenarios: 1. An application has two databases, one database is for orders, and the other database is for points. It requires points to […]

Redis principles cache expiration, consistent hashing, avalanche, penetration, concurrency, blooming, cache update strategy, cache database consistency

redis expiration policy The expiration policy of redis can be configured through the configuration file 1. Regular deletion Redis will put the keys with expiration time set in a separate dictionary, and periodically traverse to delete the expired keys. 1). Randomly select 20 keys from the expired dictionary every 100ms and delete the expired keys; […]

JAVA-EE completes the bank transfer business in MVC mode without using ThreadLocal to ensure the consistency of the Connection object by passing parameters to ensure transactions——Computer Network Classic

package com.bjpowernode.Bank.Dao; import com.bjpowernode.Bank.Pojo.Account; import java.sql.Connection; import java.util.List; public interfaceAccountDao { //DAO,Data Access Object data access object //The naming specification depends on the name of the table being processed int insert(Account account, Connection connection); int deleteByActno(Long id, Connection connection); int update(Account account, Connection connection); Account selectByActno(String actno, Connection connection); List<Account> selectAll(Connection connection); } package com.bjpowernode.Bank.Dao; […]

How to ensure data consistency in a distributed system?

Introduction Today, when distributed systems and microservice architecture are popular, it has become normal for services to fail to call each other. How to handle exceptions and how to ensure data consistency has become an unavoidable problem in the microservice design process. In different business scenarios, the solutions will be different. Common methods are: Blocking […]

Distributed things [XA strong consistency distributed transaction practice, Seata provides XA mode to implement distributed transactions] Multi-data source configuration

Reprint: https://mp.weixin.qq.com/s/1_xxMi9WPhHaMdcIc2H7pA — Note that 0.3.0 + adds unique index ux_undo_log here CREATE TABLE `undo_log` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `branch_id` bigint(20) NOT NULL, `xid` varchar(100) NOT NULL, `context` varchar(128) NOT NULL, `rollback_info` longblob NOT NULL, `log_status` int(11) NOT NULL, `log_created` datetime NOT NULL, `log_modified` datetime NOT NULL, `ext` varchar(100) DEFAULT NULL, PRIMARY KEY […]