内存数据库H2的Clustering模式数据操作测试 (3)

 

Test_Delete:

  1. 初始数据:

Server1:

ID  

NAME  

1

1

2

2

3

3

4

4

5

5

Server2:

ID  

NAME  

1

1

2

2

4

4

5

5

6

6

 

  1. Server1Server2正常启动,Client基于Server1

delete from test where id = 1;

delete from test where id = 3;

delete from test where id = 6;

commit;

 

结果:

delete from test where id = 1;

Update count: 1

(16 ms)

 

delete from test where id = 3;

Update count: 0

(0 ms)

 

delete from test where id = 6;

Update count: 1

(0 ms)

 

Server1:

ID  

NAME  

2

2

4

4

5

5

 

Server2:

ID  

NAME  

2

2

4

4

5

5

 

说明更新对两个DB都启作用了,即使DB中的记录不一致

 

  1. 重启Server1Client 不重连接(基于Server2

delete from test where id = 5;        

commit;

insert into test values (6, '6');

insert into test values (7, '7');

commit;

delete from test where id = 6;

commit;

 

结果:

delete from test where id = 5;

Update count: 1

(0 ms)

 

commit;

Update count: 0

(0 ms)

 

insert into test values (6, '6');

Update count: 1

(0 ms)

 

insert into test values (7, '7');

Update count: 1

(0 ms)

 

commit;

Update count: 0

(0 ms)

 

delete from test where id = 6;

Update count: 1

(0 ms)

 

commit;

Update count: 0

(0 ms)

 

Server1:

ID  

NAME  

2

2

4

4

5

5

 

Server2:

ID  

NAME  

2

2

4

4

7

7

 

 

说明没重连,对Server2的操作没有同步到Server1

 

  1. 重启Server2Client 不重连接(基于Server1

delete from test where id = 2;                

delete from test where id = 5;        

commit;

insert into test values (6, '6');

insert into test values (7, '7');

commit;

delete from test where id = 6;

commit;

 

结果:

delete from test where id = 2;

Update count: 1

(16 ms)

 

delete from test where id = 5;

Update count: 1

(0 ms)

 

commit;

Update count: 0

(0 ms)

 

insert into test values (6, '6');

Update count: 1

(0 ms)

 

insert into test values (7, '7');

Update count: 1

(0 ms)

 

commit;

Update count: 0

(0 ms)

 

delete from test where id = 6;

Update count: 1

(0 ms)

 

commit;

Update count: 0

(0 ms)

 

Server1:

ID  

NAME  

4

4

7

7

 

Server2:

ID  

NAME  

2

2

4

4

7

7

说明没重连,Server2没有影响

 

 

 

 

 

 

*********************************************************************************************************

*********************************************************************************************************

*********************************************************************************************************

*********************************************************************************************************

Init data:

CREATE TABLE TEST2(ID IDENTITY , NAME VARCHAR);

 

Test_Insert:

  1. Server1Server2正常启动,ClientServer1为基础

insert into test2(name) values ('1');

insert into test2(name) values ('2');

insert into test2(name) values ('3');

insert into test2(name) values ('4');

insert into test2(name) values ('5');

 

结果:

insert into test2(name) values ('1');

Update count: 1

(16 ms)

 

insert into test2(name) values ('2');

Update count: 1

(0 ms)

 

insert into test2(name) values ('3');

Update count: 1

(0 ms)

 

insert into test2(name) values ('4');

Update count: 1

(0 ms)

 

insert into test2(name) values ('5');

Update count: 1

(0 ms)

 

Server1:

ID  

NAME  

1

1

2

2

3

3

4

4

5

5

Server2:

ID  

NAME  

1

1

2

2

3

3

4

4

5

5

 

  1. 重启Server1,客户端不重新连接(此时,select操作的数据是以server2为准)

执行:

delete from test2 where id = 5;

insert into test2(name) values (6);

insert into test2(name) values (7);

 

执行结果

delete from test2 where id = 5;

Update count: 1

(0 ms)

 

insert into test2(name) values (6);

Update count: 1

(0 ms)

 

insert into test2(name) values (7);

Update count: 1

(0 ms)

 

Server1

ID  

NAME  

1

1

2

2

3

3

4

4

5

5

 

Client/Server2:

ID  

NAME  

1

1

2

2

3

3

4

4

6

6

7

7

说明没重连,对Server2的操作没有同步到Server1

 

  1. Server1, Server2正常工作,

客户端重新连接(读以Server1)为主

 

执行:

delete from test2 where id = 4;        

delete from test2 where id = 5;

insert into test2(name) values (6);

insert into test2(name) values (7);

 

结果:

delete from test2 where id = 4;

Update count: 1

(16 ms)

 

delete from test2 where id = 5;

Update count: 0

(0 ms)

 

insert into test2(name) values (6);

Update count: 1

(0 ms)

 

insert into test2(name) values (7);

Update count: 1

(0 ms)

 

Client (Server1):

ID  

NAME  

1

1

2

2

3

3

6

6

7

7

 

Server2:

ID  

NAME  

1

1

2

2

3

3

6

6

7

7

8

6

9

7

 

Server2中插入了两条67,说明是分别做的操作

你可能感兴趣的:(工作)