{"record":{"id":"16eb45adbe5950dc","repo":"apache/beam","slug":"can-not-get-unique-key-from-solr","errorCode":null,"errorMessage":"Can not get unique key from solr","messagePattern":"Can not get unique key from solr","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/solr/src/main/java/org/apache/beam/sdk/io/solr/SolrIO.java","lineNumber":465,"sourceCode":"    public void process(@Element Read spec, OutputReceiver<SolrDocument> out) throws IOException {\n      ReplicaInfo replicaInfo = spec.getReplicaInfo();\n      checkArgument(replicaInfo != null, \"replicaInfo is required\");\n      String cursorMark = CursorMarkParams.CURSOR_MARK_START;\n      String query = spec.getQuery();\n      if (query == null) {\n        query = \"*:*\";\n      }\n      SolrQuery solrQuery = new SolrQuery(query);\n      solrQuery.setRows(spec.getBatchSize());\n      solrQuery.setDistrib(false);\n      try (AuthorizedSolrClient<HttpSolrClient> client =\n          spec.getConnectionConfiguration().createClient(replicaInfo.baseUrl())) {\n        SchemaRequest.UniqueKey request = new SchemaRequest.UniqueKey();\n        try {\n          SchemaResponse.UniqueKeyResponse response = client.process(spec.getCollection(), request);\n          solrQuery.addSort(response.getUniqueKey(), SolrQuery.ORDER.asc);\n        } catch (SolrServerException e) {\n          throw new IOException(\"Can not get unique key from solr\", e);\n        }\n\n        while (true) {\n          solrQuery.set(CursorMarkParams.CURSOR_MARK_PARAM, cursorMark);\n          try {\n            QueryResponse response;\n            response = client.query(replicaInfo.coreName(), solrQuery);\n            if (cursorMark.equals(response.getNextCursorMark())) {\n              break;\n            }\n            cursorMark = response.getNextCursorMark();\n            for (SolrDocument doc : response.getResults()) {\n              out.output(doc);\n            }\n          } catch (SolrServerException e) {\n            throw new IOException(e);\n          }\n        }","sourceCodeStart":447,"sourceCodeEnd":483,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/solr/src/main/java/org/apache/beam/sdk/io/solr/SolrIO.java#L447-L483","documentation":"SolrIO's cursor-based (deep-paging) read first queries Solr for the collection's unique key field to sort results deterministically. If the Solr server throws SolrServerException during that SchemaRequest.UniqueKey lookup, the connector wraps it in this IOException and aborts the read.","triggerScenarios":"client.process(collection, SchemaRequest.UniqueKey) fails — e.g. Solr node unreachable/overloaded, collection name wrong, schema API disabled, or replica returning errors.","commonSituations":"Misconfigured collection name or connection URL; Solr Cloud node down or in recovery; firewalls/security plugins blocking the schema API endpoint.","solutions":["Verify the collection name and connection configuration (zkHost/URL) are correct","Check Solr server health and that the schema API (/schema/uniquekey) is reachable and permitted","Inspect the wrapped SolrServerException cause for the root network/server error and fix connectivity or scale the Solr cluster","Retry after Solr finishes recovery/migrations"],"exampleFix":"// before\nSolrIO.read().withConnectionConfiguration(SolrIO.ConnectionConfiguration.create(\"bad-host:9983\",\"docs\"));\n// after\nSolrIO.read().withConnectionConfiguration(SolrIO.ConnectionConfiguration.create(\"zk1:9983,zk2:9983\",\"docs\"));","handlingStrategy":"retry","validationCode":"// preflight: verify collection and schema API reachable\ntry (SolrClient c = connConfig.createClient(baseUrl)) {\n  c.process(collection, new SchemaRequest.UniqueKey());\n}","typeGuard":null,"tryCatchPattern":"try {\n  readFromSolr();\n} catch (IOException e) {\n  if (e.getCause() instanceof SolrServerException) {\n    LOG.error(\"Solr unique-key lookup failed; check collection/cluster health\", e);\n  }\n  throw e;\n}","preventionTips":["Validate collection names and connection config before launching","Monitor Solr Cloud node health/recovery states","Ensure schema API endpoints are not blocked by security plugins","Add retry logic around read pipelines for transient Solr errors"],"tags":["java","beam","solr","network","io"],"backgroundTag":"database-query-failed","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T21:17:11.552Z"}