无法从流中反序列化异常响应 - Grails ElasticSearch

时间:2013-11-22 15:22:49

标签: grails elasticsearch

我有一个简单的Grails应用程序,我试图将其设置为使用ElasticSearch。

我在EC2上运行了一个单节点ElasticSearch实例,该实例运行得非常愉快。 (作为参考,我只是按照这里的步骤:http://www.elasticsearch.org/tutorials/elasticsearch-on-ec2/),但使用0.90.7和cloud-aws插件版本1.15.0)

我正在使用Grails ElasticSearch GORM插件(http://grails.org/plugin/elasticsearch-gorm)(主分支),我正在使用传输客户端模式连接到ES(elasticSearch.client.mode ='transport')

这里真的很奇怪......

我第一次启动我的应用程序时,它会愉快地在ES上索引我的域数据,我可以查询等,没有问题。

如果我重新启动我的grails应用程序,它将根本无法启动。我得到了

消息:创建名为'searchableClassMappingConfigurator'的bean时出错:init方法的调用失败;嵌套异常是org.elasticsearch.transport.TransportSerializationException:无法从流中反序列化异常响应

    Line | Method
->>  262 | run       in java.util.concurrent.FutureTask
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    724 | run       in java.lang.Thread
Caused by TransportSerializationException: Failed to deserialize exception response from stream
->>  169 | handlerResponseError in org.elasticsearch.transport.netty.MessageChannelHandler
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    123 | messageReceived in     ''
|     70 | handleUpstream in org.elasticsearch.common.netty.channel.SimpleChannelUpstreamHandler
|    564 | sendUpstream in org.elasticsearch.common.netty.channel.DefaultChannelPipeline
|    791 | sendUpstream in org.elasticsearch.common.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext
|    296 | fireMessageReceived in org.elasticsearch.common.netty.channel.Channels
|    462 | unfoldAndFireMessageReceived in org.elasticsearch.common.netty.handler.codec.frame.FrameDecoder
|    443 | callDecode in     ''
|    310 | messageReceived in     ''
|     70 | handleUpstream in org.elasticsearch.common.netty.channel.SimpleChannelUpstreamHandler
|    564 | sendUpstream in org.elasticsearch.common.netty.channel.DefaultChannelPipeline
|    559 | sendUpstream in     ''
|    268 | fireMessageReceived in org.elasticsearch.common.netty.channel.Channels
|    255 | fireMessageReceived in     ''
|     88 | read . .  in org.elasticsearch.common.netty.channel.socket.nio.NioWorker
|    108 | process   in org.elasticsearch.common.netty.channel.socket.nio.AbstractNioWorker
|    318 | run . . . in org.elasticsearch.common.netty.channel.socket.nio.AbstractNioSelector
|     89 | run       in org.elasticsearch.common.netty.channel.socket.nio.AbstractNioWorker
|    178 | run . . . in org.elasticsearch.common.netty.channel.socket.nio.NioWorker
|    108 | run       in org.elasticsearch.common.netty.util.ThreadRenamingRunnable
|     42 | run . . . in org.elasticsearch.common.netty.util.internal.DeadLockProofWorker$1
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    724 | run       in java.lang.Thread
Caused by StreamCorruptedException: unexpected end of block data
->> 1370 | readObject0 in java.io.ObjectInputStream
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   1989 | defaultReadFields in     ''
|    499 | defaultReadObject in     ''
|    914 | readObject in java.lang.Throwable
|   1017 | invokeReadObject in java.io.ObjectStreamClass
|   1891 | readSerialData in java.io.ObjectInputStream
|   1796 | readOrdinaryObject in     ''
|   1348 | readObject0 in     ''
|   1989 | defaultReadFields in     ''
|    499 | defaultReadObject in     ''
|    914 | readObject in java.lang.Throwable
|   1017 | invokeReadObject in java.io.ObjectStreamClass
|   1891 | readSerialData in java.io.ObjectInputStream
|   1796 | readOrdinaryObject in     ''
|   1348 | readObject0 in     ''
|    370 | readObject in     ''
|    167 | handlerResponseError in org.elasticsearch.transport.netty.MessageChannelHandler
|    123 | messageReceived in     ''
|     70 | handleUpstream in org.elasticsearch.common.netty.channel.SimpleChannelUpstreamHandler
|    564 | sendUpstream in org.elasticsearch.common.netty.channel.DefaultChannelPipeline
|    791 | sendUpstream in org.elasticsearch.common.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext
|    296 | fireMessageReceived in org.elasticsearch.common.netty.channel.Channels
|    462 | unfoldAndFireMessageReceived in org.elasticsearch.common.netty.handler.codec.frame.FrameDecoder
|    443 | callDecode in     ''
|    310 | messageReceived in     ''
|     70 | handleUpstream in org.elasticsearch.common.netty.channel.SimpleChannelUpstreamHandler
|    564 | sendUpstream in org.elasticsearch.common.netty.channel.DefaultChannelPipeline
|    559 | sendUpstream in     ''
|    268 | fireMessageReceived in org.elasticsearch.common.netty.channel.Channels
|    255 | fireMessageReceived in     ''
|     88 | read . .  in org.elasticsearch.common.netty.channel.socket.nio.NioWorker
|    108 | process   in org.elasticsearch.common.netty.channel.socket.nio.AbstractNioWorker
|    318 | run . . . in org.elasticsearch.common.netty.channel.socket.nio.AbstractNioSelector
|     89 | run       in org.elasticsearch.common.netty.channel.socket.nio.AbstractNioWorker
|    178 | run . . . in org.elasticsearch.common.netty.channel.socket.nio.NioWorker
|    108 | run       in org.elasticsearch.common.netty.util.ThreadRenamingRunnable
|     42 | run . . . in org.elasticsearch.common.netty.util.internal.DeadLockProofWorker$1
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    724 | run       in java.lang.Thread

这种情况发生在我更改elasticSearch主机详细信息之前 - 即,我无法再次使用原始主机详细信息启动我的ap

ES节点和我的Grails应用程序都使用elasticSearch 0.90.7,我的ES插件配置如下:@

elasticSearch.client.mode = 'transport'
elasticSearch.client.hosts = [[host:'<my EC2 DNS>', port:9300]]
elasticSearch.datastoreImpl = 'mongoDatastore'
elasticSearch.client.transport.sniff = true

我标记为'searchable'的唯一域对象使用mongoDB映射,如下所示:

class CompletedApplicationFormSearchEntry {
    static searchable = true
    Long formId
    Long jobId
    Long employerId
    Long jobseekerId
    Date applicationDate

    static mapWith = "mongo"

    static constraints = {
    }
}

如果我从域类中删除了可搜索的属性,然后重新启动应用程序,它启动正常,所以我认为当域对象被检测为可搜索时,在引导过程中会发生一些事情,但当然,它只有在应用程序重新启动时才会出现问题。

有一些线程在人们看到类似问题的地方踢,他们有节点运行不同的ES版本,不同的JVM版本,等等。但在这种情况下,我只有一个节点!

我绝对是在撕扯我的头发 - 我无法弄清楚究竟出了什么问题。我尝试了不同的插件版本,elasticsearch版本,32位EC2实例,64位EC2实例 - 没有运气!

2 个答案:

答案 0 :(得分:1)

不使用grails es插件,但我通过将ide中的jvm版本(由es客户端使用)修复为与在不同jvm版本上运行的es master相同来修复类似问题。

步骤0:确保api和实际版本相同。

步骤1:检查es节点使用的jvm版本

在下面的例子中,我有两个不同的jvm版本,正如&#34; jvm&#34;两个es nodes的json键。

$ curl -XGET "http://localhost:9200/_nodes?jvm=true&pretty=true"
{
  "cluster_name" : "elasticsearch",
  "nodes" : {
    "A6PDUvlWSN-zN2GKRxrSHA" : {
      "name" : "Madeline Joyce",
      "transport_address" : "inet[/192.168.1.4:9301]",
      "host" : "prayagupd",
      "ip" : "127.0.1.1",
      "version" : "1.3.2",
      "build" : "dee175d",
      "http_address" : "inet[/192.168.1.4:9201]",
      "settings" : {
        "path" : {
          "logs" : "/usr/local/elasticsearch-1.3.2/logs",
          "home" : "/usr/local/elasticsearch-1.3.2"
        },
        "cluster" : {
          "name" : "elasticsearch"
        },
        "http" : {
          "port" : "9201"
        },
        "transport" : {
          "tcp" : {
            "port" : "9301"
          }
        },
        "foreground" : "yes",
        "name" : "Madeline Joyce"
      },
      "os" : {
        "refresh_interval_in_millis" : 1000,
        "available_processors" : 4,
        "cpu" : {
          "vendor" : "Intel",
          "model" : "Core(TM) i5 CPU       M 480  @ 2.67GHz",
          "mhz" : 2667,
          "total_cores" : 4,
          "total_sockets" : 4,
          "cores_per_socket" : 16,
          "cache_size_in_bytes" : 3072
        },
        "mem" : {
          "total_in_bytes" : 3803283456
        },
        "swap" : {
          "total_in_bytes" : 5998899200
        }
      },
      "process" : {
        "refresh_interval_in_millis" : 1000,
        "id" : 9036,
        "max_file_descriptors" : 4096,
        "mlockall" : false
      },
      "jvm" : {
        "pid" : 9036,
        "version" : "1.7.0_65",
        "vm_name" : "Java HotSpot(TM) 64-Bit Server VM",
        "vm_version" : "24.65-b04",
        "vm_vendor" : "Oracle Corporation",
        "start_time_in_millis" : 1421578674811,
        "mem" : {
          "heap_init_in_bytes" : 268435456,
          "heap_max_in_bytes" : 1038876672,
          "non_heap_init_in_bytes" : 24313856,
          "non_heap_max_in_bytes" : 136314880,
          "direct_max_in_bytes" : 1038876672
        },
        "gc_collectors" : [ "ParNew", "ConcurrentMarkSweep" ],
        "memory_pools" : [ "Code Cache", "Par Eden Space", "Par Survivor Space", "CMS Old Gen", "CMS Perm Gen" ]
      },
      "thread_pool" : {
        "generic" : {
          "type" : "cached",
          "keep_alive" : "30s",
          "queue_size" : -1
        },
        "index" : {
          "type" : "fixed",
          "min" : 4,
          "max" : 4,
          "queue_size" : "200"
        },
        "snapshot_data" : {
          "type" : "scaling",
          "min" : 1,
          "max" : 5,
          "keep_alive" : "5m",
          "queue_size" : -1
        },
        "bench" : {
          "type" : "scaling",
          "min" : 1,
          "max" : 2,
          "keep_alive" : "5m",
          "queue_size" : -1
        },
        "get" : {
          "type" : "fixed",
          "min" : 4,
          "max" : 4,
          "queue_size" : "1k"
        },
        "snapshot" : {
          "type" : "scaling",
          "min" : 1,
          "max" : 2,
          "keep_alive" : "5m",
          "queue_size" : -1
        },
        "merge" : {
          "type" : "scaling",
          "min" : 1,
          "max" : 2,
          "keep_alive" : "5m",
          "queue_size" : -1
        },
        "suggest" : {
          "type" : "fixed",
          "min" : 4,
          "max" : 4,
          "queue_size" : "1k"
        },
        "bulk" : {
          "type" : "fixed",
          "min" : 4,
          "max" : 4,
          "queue_size" : "50"
        },
        "optimize" : {
          "type" : "fixed",
          "min" : 1,
          "max" : 1,
          "queue_size" : -1
        },
        "warmer" : {
          "type" : "scaling",
          "min" : 1,
          "max" : 2,
          "keep_alive" : "5m",
          "queue_size" : -1
        },
        "flush" : {
          "type" : "scaling",
          "min" : 1,
          "max" : 2,
          "keep_alive" : "5m",
          "queue_size" : -1
        },
        "search" : {
          "type" : "fixed",
          "min" : 12,
          "max" : 12,
          "queue_size" : "1k"
        },
        "percolate" : {
          "type" : "fixed",
          "min" : 4,
          "max" : 4,
          "queue_size" : "1k"
        },
        "management" : {
          "type" : "scaling",
          "min" : 1,
          "max" : 5,
          "keep_alive" : "5m",
          "queue_size" : -1
        },
        "refresh" : {
          "type" : "scaling",
          "min" : 1,
          "max" : 2,
          "keep_alive" : "5m",
          "queue_size" : -1
        }
      },
      "network" : {
        "refresh_interval_in_millis" : 5000,
        "primary_interface" : {
          "address" : "192.168.1.4",
          "name" : "eth0",
          "mac_address" : "20:6A:8A:2A:24:E6"
        }
      },
      "transport" : {
        "bound_address" : "inet[/0:0:0:0:0:0:0:0%0:9301]",
        "publish_address" : "inet[/192.168.1.4:9301]"
      },
      "http" : {
        "bound_address" : "inet[/0:0:0:0:0:0:0:0%0:9201]",
        "publish_address" : "inet[/192.168.1.4:9201]",
        "max_content_length_in_bytes" : 104857600
      },
      "plugins" : [ ]
    },
    "TWNkkYYZSWe8NnrOPU57mQ" : {
      "name" : "Scarlet Spider",
      "transport_address" : "inet[/192.168.1.4:9300]",
      "host" : "prayagupd",
      "ip" : "127.0.1.1",
      "version" : "1.3.2",
      "build" : "dee175d",
      "http_address" : "inet[/192.168.1.4:9200]",
      "attributes" : {
        "client" : "true",
        "data" : "false"
      },
      "settings" : {
        "path" : {
          "data" : "/var/lib/elasticsearch",
          "work" : "/tmp/elasticsearch",
          "conf" : "/etc/elasticsearch",
          "logs" : "/var/log/elasticsearch"
        },
        "cluster" : {
          "name" : "elasticsearch"
        },
        "node" : {
          "client" : "true"
        },
        "name" : "Scarlet Spider"
      },
      "os" : {
        "refresh_interval_in_millis" : 1000,
        "available_processors" : 4
      },
      "process" : {
        "refresh_interval_in_millis" : 1000,
        "id" : 11028,
        "max_file_descriptors" : 4096,
        "mlockall" : false
      },
      "jvm" : {
        "pid" : 11028,
        "version" : "1.7.0_05",
        "vm_name" : "Java HotSpot(TM) 64-Bit Server VM",
        "vm_version" : "23.1-b03",
        "vm_vendor" : "Oracle Corporation",
        "start_time_in_millis" : 1421580829189,
        "mem" : {
          "heap_init_in_bytes" : 59426304,
          "heap_max_in_bytes" : 846331904,
          "non_heap_init_in_bytes" : 24313856,
          "non_heap_max_in_bytes" : 136314880,
          "direct_max_in_bytes" : 846331904
        },
        "gc_collectors" : [ "PS Scavenge", "PS MarkSweep" ],
        "memory_pools" : [ "Code Cache", "PS Eden Space", "PS Survivor Space", "PS Old Gen", "PS Perm Gen" ]
      },
      "thread_pool" : {
        "generic" : {
          "type" : "cached",
          "keep_alive" : "30s",
          "queue_size" : -1
        },
        "index" : {
          "type" : "fixed",
          "min" : 4,
          "max" : 4,
          "queue_size" : "200"
        },
        "snapshot_data" : {
          "type" : "scaling",
          "min" : 1,
          "max" : 5,
          "keep_alive" : "5m",
          "queue_size" : -1
        },
        "bench" : {
          "type" : "scaling",
          "min" : 1,
          "max" : 2,
          "keep_alive" : "5m",
          "queue_size" : -1
        },
        "get" : {
          "type" : "fixed",
          "min" : 4,
          "max" : 4,
          "queue_size" : "1k"
        },
        "snapshot" : {
          "type" : "scaling",
          "min" : 1,
          "max" : 2,
          "keep_alive" : "5m",
          "queue_size" : -1
        },
        "merge" : {
          "type" : "scaling",
          "min" : 1,
          "max" : 2,
          "keep_alive" : "5m",
          "queue_size" : -1
        },
        "suggest" : {
          "type" : "fixed",
          "min" : 4,
          "max" : 4,
          "queue_size" : "1k"
        },
        "bulk" : {
          "type" : "fixed",
          "min" : 4,
          "max" : 4,
          "queue_size" : "50"
        },
        "optimize" : {
          "type" : "fixed",
          "min" : 1,
          "max" : 1,
          "queue_size" : -1
        },
        "warmer" : {
          "type" : "scaling",
          "min" : 1,
          "max" : 2,
          "keep_alive" : "5m",
          "queue_size" : -1
        },
        "flush" : {
          "type" : "scaling",
          "min" : 1,
          "max" : 2,
          "keep_alive" : "5m",
          "queue_size" : -1
        },
        "search" : {
          "type" : "fixed",
          "min" : 12,
          "max" : 12,
          "queue_size" : "1k"
        },
        "percolate" : {
          "type" : "fixed",
          "min" : 4,
          "max" : 4,
          "queue_size" : "1k"
        },
        "management" : {
          "type" : "scaling",
          "min" : 1,
          "max" : 5,
          "keep_alive" : "5m",
          "queue_size" : -1
        },
        "refresh" : {
          "type" : "scaling",
          "min" : 1,
          "max" : 2,
          "keep_alive" : "5m",
          "queue_size" : -1
        }
      },
      "network" : {
        "refresh_interval_in_millis" : 5000
      },
      "transport" : {
        "bound_address" : "inet[/0:0:0:0:0:0:0:0:9300]",
        "publish_address" : "inet[/192.168.1.4:9300]"
      },
      "http" : {
        "bound_address" : "inet[/0:0:0:0:0:0:0:0:9200]",
        "publish_address" : "inet[/192.168.1.4:9200]",
        "max_content_length_in_bytes" : 104857600
      },
      "plugins" : [ ]
    }
  }
}

第2步:在ide中更新jvm版本(以下显示为intellij ide)

enter image description here

更新到所需的jvm版本,并添加到项目

enter image description here

第3步:运行两个es节点,TransportSerializationException的问题应该得到修复

$ curl -XGET "http://localhost:9200/_nodes?jvm=true&pretty=true"
{
  "cluster_name": "elasticsearch",
  "nodes": {
    "GeRZFRiDSje8zLM_m90WRw": {
      "name" : "Dougboy",
      "jvm": {
        "pid": 15223,
        "version": "1.7.0_65",
        "vm_name": "Java HotSpot(TM) 64-Bit Server VM",
        "vm_version": "24.65-b04",
        "vm_vendor": "Oracle Corporation",
        "start_time_in_millis": 1421586819876,
        "mem": {
          "heap_init_in_bytes": 59426304,
          "heap_max_in_bytes": 846200832,
          "non_heap_init_in_bytes": 24576000,
          "non_heap_max_in_bytes": 136314880,
          "direct_max_in_bytes": 846200832
        }
      }
    },
    "A6PDUvlWSN-zN2GKRxrSHA": {
      "name": "Madeline Joyce",
      "jvm": {
        "pid": 9036,
        "version": "1.7.0_65",
        "vm_name": "Java HotSpot(TM) 64-Bit Server VM",
        "vm_version": "24.65-b04",
        "vm_vendor": "Oracle Corporation",
        "start_time_in_millis": 1421578674811,
        "mem": {
          "heap_init_in_bytes": 268435456,
          "heap_max_in_bytes": 1038876672,
          "non_heap_init_in_bytes": 24313856,
          "non_heap_max_in_bytes": 136314880,
          "direct_max_in_bytes": 1038876672
        }
      }
    }
  }
}

参考

Java Client TransportSerializationException #3835, Oct 6, 2013

答案 1 :(得分:0)

看起来这个插件的问题是Elasticsearch 0.90.7抛出一个未被插件捕获的异常。

在此处提取请求:https://github.com/mstein/elasticsearch-grails-plugin/pull/74有一个修复程序并包含ES 0.90.7