google-code-export / h2database

Automatically exported from code.google.com/p/h2database
0 stars 1 forks source link

Cluster: No admin rights user can't connect if one cluster node is stopped #206

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago

This issue connects with issue 201("No admin rights user can't connect to 
clustered database.")

What steps will reproduce the problem?
(simple SQL scripts or simple standalone applications are preferred)
1.create clustered database.

java -cp d:\temp\h2-1.2.137.jar org.h2.tools.Server -tcp -tcpPort 9101 -
baseDir D:\temp\server1
java -cp d:\temp\h2-1.2.137.jar org.h2.tools.Server -tcp -tcpPort 9102 -
baseDir D:\temp\server2
java -cp d:\temp\h2-1.2.137.jar org.h2.tools.CreateCluster -urlSource 
jdbc:h2:tcp://localhost:9101/testdb -urlTarget 
jdbc:h2:tcp://localhost:9102/testdb -user admin -password admin -
serverList localhost:9101,localhost:9102

2. connect to database and create user who has no admin rights.

java -cp d:\temp\h2-1.2.137.jar org.h2.tools.Shell -url 
jdbc:h2:tcp://localhost:9101,localhost:9102/testdb -user admin -password 
admin -sql "create user test password 'test'";

3. connect to clusterd database by test user(who has no admin rights)

java -cp d:\temp\h2-1.2.137.jar org.h2.tools.Shell -url 
jdbc:h2:tcp://localhost:9101,localhost:9102/testdb -user test -password 
test

4. kill any node (and switch off cluster mode).

5. connect to clusterd database by test user (new connection)

java -cp d:\temp\h2-1.2.137.jar org.h2.tools.Shell -url 
jdbc:h2:tcp://localhost:9101,localhost:9102/testdb -user test -password 
test

Exception in thread "main" org.h2.jdbc.JdbcSQLException: 
この操作には管理権限
が
必要です
Admin rights are required for this operation; SQL statement:
SET CLUSTER 'localhost:9101,localhost:9102' [90040-137]
        at org.h2.message.DbException.getJdbcSQLException
(DbException.java:327)
        at org.h2.message.DbException.get(DbException.java:167)
        at org.h2.message.DbException.get(DbException.java:144)
        at org.h2.message.DbException.get(DbException.java:133)
        at org.h2.engine.User.checkAdmin(User.java:195)
        at org.h2.command.dml.Set.update(Set.java:89)
        at org.h2.command.CommandContainer.update(CommandContainer.java:70)
        at org.h2.command.Command.executeUpdate(Command.java:199)
        at org.h2.engine.Engine.openSession(Engine.java:164)
        at org.h2.engine.Engine.getSession(Engine.java:125)
        at org.h2.server.TcpServerThread.run(TcpServerThread.java:118)
        at java.lang.Thread.run(Thread.java:619)

        at org.h2.engine.SessionRemote.done(SessionRemote.java:528)
        at org.h2.engine.SessionRemote.initTransfer(SessionRemote.java:114)
        at org.h2.engine.SessionRemote.connectServer
(SessionRemote.java:325)
        at org.h2.engine.SessionRemote.connectEmbeddedOrServer
(SessionRemote.jav
a:223)
        at org.h2.engine.SessionRemote.createSession
(SessionRemote.java:217)
        at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:111)
        at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:95)
        at org.h2.Driver.connect(Driver.java:58)
        at java.sql.DriverManager.getConnection(DriverManager.java:582)
        at java.sql.DriverManager.getConnection(DriverManager.java:185)
        at org.h2.tools.Shell.runTool(Shell.java:140)
        at org.h2.tools.Shell.main(Shell.java:78)

What is the expected output? What do you see instead?

I can connect database that is disabled cluster mode.

What version of the product are you using? On what operating system, file
system, and virtual machine?

H2 Version 1.2.137 (2010-06-06)

Do you know a workaround?

I don't know.

How important/urgent is the problem for you?

important

In your view, is this a defect or a feature request?

defect

Please provide any additional information below.

Original issue reported on code.google.com by litail...@gmail.com on 7 Jun 2010 at 2:40

GoogleCodeExporter commented 9 years ago
Hi,

Yes, this is a bug. It will be fixed in the next release. I will commit the 
changes
later today. 

Thanks a lot for your help! 

Regards,
Thomas

Original comment by thomas.t...@gmail.com on 7 Jun 2010 at 6:55

GoogleCodeExporter commented 9 years ago
Fixed in version 1.2.138.

Original comment by thomas.t...@gmail.com on 28 Jun 2010 at 4:51