[Groonga-commit] groonga/groonga at 9f53159 [master] grndb check: support recursive check for index column

アーカイブの一覧に戻る

Kouhei Sutou null+****@clear*****
Mon Jan 25 18:11:39 JST 2016


Kouhei Sutou	2016-01-25 18:11:39 +0900 (Mon, 25 Jan 2016)

  New Revision: 9f53159a121256ee7ce3465ad25674938c1ffedd
  https://github.com/groonga/groonga/commit/9f53159a121256ee7ce3465ad25674938c1ffedd

  Message:
    grndb check: support recursive check for index column

  Modified files:
    lib/mrb/scripts/command_line/grndb.rb
    test/command_line/suite/grndb/test_check.rb

  Modified: lib/mrb/scripts/command_line/grndb.rb (+20 -1)
===================================================================
--- lib/mrb/scripts/command_line/grndb.rb    2016-01-25 18:08:06 +0900 (7861624)
+++ lib/mrb/scripts/command_line/grndb.rb    2016-01-25 18:11:39 +0900 (27d76fb)
@@ -191,7 +191,7 @@ module Groonga
               record = Record.new(database, column_id)
               failed_to_open(record.key)
             else
-              check_object(column, options, arguments)
+              check_object_recursive(database, column, options, arguments)
             end
           end
         when FixedSizeColumn, VariableSizeColumn
@@ -203,6 +203,25 @@ module Groonga
           elsif range.is_a?(Table)
             check_object_recursive(database, range, options, arguments)
           end
+        when IndexColumn
+          range_id = target.range_id
+          range = context[range_id]
+          if range.nil?
+            record = Record.new(database, range_id)
+            failed_to_open(record.key)
+            return
+          end
+          check_object(range, options, arguments)
+
+          target.source_ids.each do |source_id|
+            source = context[source_id]
+            if source.nil?
+              record = Record.new(database, source_id)
+              failed_to_open(record.key)
+            elsif source.is_a?(Column)
+              check_object_recursive(database, source, options, arguments)
+            end
+          end
         end
       end
 

  Modified: test/command_line/suite/grndb/test_check.rb (+52 -0)
===================================================================
--- test/command_line/suite/grndb/test_check.rb    2016-01-25 18:08:06 +0900 (6ea63fb)
+++ test/command_line/suite/grndb/test_check.rb    2016-01-25 18:11:39 +0900 (e185da3)
@@ -111,5 +111,57 @@ Database is locked. It may be broken. Re-create the database.
 [Users.age] Data column is locked. It may be broken. (1) Truncate the column (truncate Users.age) or clear lock of the column (lock_clear Users.age) and (2) load data again.
       MESSAGE
     end
+
+    def test_locked_index_column
+      groonga("table_create", "Users", "TABLE_HASH_KEY", "ShortText")
+      groonga("column_create", "Users", "age", "COLUMN_SCALAR", "UInt8")
+      groonga("column_create", "Users", "name", "COLUMN_SCALAR", "ShortText")
+
+      groonga("table_create", "Ages", "TABLE_PAT_KEY", "UInt8")
+      groonga("column_create", "Ages", "users_age", "COLUMN_INDEX",
+              "Users", "age")
+
+      groonga("lock_acquire", "Users")
+      groonga("lock_acquire", "Users.age")
+      groonga("lock_acquire", "Users.name")
+      groonga("lock_acquire", "Ages")
+      groonga("lock_acquire", "Ages.users_age")
+
+      error = assert_raise(CommandRunner::Error) do
+        grndb("check", "--target", "Ages")
+      end
+      assert_equal(<<-MESSAGE, error.error_output)
+[Ages] Table is locked. It may be broken. (1) Truncate the table (truncate Ages) or clear lock of the table (lock_clear Ages) and (2) load data again.
+[Ages.users_age] Index column is locked. It may be broken. Re-create index by '#{grndb_path} recover #{@database_path}'.
+[Users] Table is locked. It may be broken. (1) Truncate the table (truncate Users) or clear lock of the table (lock_clear Users) and (2) load data again.
+[Users.age] Data column is locked. It may be broken. (1) Truncate the column (truncate Users.age) or clear lock of the column (lock_clear Users.age) and (2) load data again.
+      MESSAGE
+    end
+
+    def test_indexed_table
+      groonga("table_create", "Users", "TABLE_HASH_KEY", "ShortText")
+      groonga("column_create", "Users", "age", "COLUMN_SCALAR", "UInt8")
+      groonga("column_create", "Users", "name", "COLUMN_SCALAR", "ShortText")
+
+      groonga("table_create", "Names", "TABLE_PAT_KEY", "ShortText")
+      groonga("column_create", "Names", "users_names",
+              "COLUMN_INDEX|WITH_SECTION", "Users", "_key,name")
+
+      groonga("lock_acquire", "Users")
+      groonga("lock_acquire", "Users.age")
+      groonga("lock_acquire", "Users.name")
+      groonga("lock_acquire", "Names")
+      groonga("lock_acquire", "Names.users_names")
+
+      error = assert_raise(CommandRunner::Error) do
+        grndb("check", "--target", "Names")
+      end
+      assert_equal(<<-MESSAGE, error.error_output)
+[Names] Table is locked. It may be broken. (1) Truncate the table (truncate Names) or clear lock of the table (lock_clear Names) and (2) load data again.
+[Names.users_names] Index column is locked. It may be broken. Re-create index by '/home/kou/work/c/groonga.mruby/src/.libs/lt-grndb recover /home/kou/work/c/groonga.mruby/test/command_line/helper/tmp/groonga-command-line/test_indexed_table-TestGrnDBCheck::--target-.db'.
+[Users] Table is locked. It may be broken. (1) Truncate the table (truncate Users) or clear lock of the table (lock_clear Users) and (2) load data again.
+[Users.name] Data column is locked. It may be broken. (1) Truncate the column (truncate Users.name) or clear lock of the column (lock_clear Users.name) and (2) load data again.
+      MESSAGE
+    end
   end
 end
-------------- next part --------------
HTML����������������������������...
ダウンロード 



More information about the Groonga-commit mailing list
アーカイブの一覧に戻る