{"record":{"id":"1e546ee4fd7b895d","repo":"prestodb/presto","slug":"invalid-kafka-offset-start-end-pair-s-s","errorCode":null,"errorMessage":"Invalid Kafka Offset start/end pair: %s - %s","messagePattern":"Invalid Kafka Offset start/end pair: (.+?) - (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"presto-kafka/src/main/java/com/facebook/presto/kafka/KafkaSplitManager.java","lineNumber":109,"sourceCode":"            KafkaTableLayoutHandle layoutHandle = (KafkaTableLayoutHandle) layout;\n            HostAddress node = KafkaClusterMetadataHelper.selectRandom(clusterMetadataSupplier.getNodes(layoutHandle.getTable().getSchemaName()));\n\n            KafkaConsumer<ByteBuffer, ByteBuffer> consumer = consumerManager.createConsumer(Thread.currentThread().getName(), node);\n            List<PartitionInfo> partitions = consumer.partitionsFor(topic);\n            ImmutableList.Builder<ConnectorSplit> splits = ImmutableList.builder();\n\n            for (PartitionInfo partition : partitions) {\n                Node leader = partition.leader();\n                if (leader == null) {\n                    throw new PrestoException(GENERIC_INTERNAL_ERROR, format(\"Leader election in progress for Kafka topic '%s' partition %s\", topic, partition.partition()));\n                }\n\n                HostAddress partitionLeader = HostAddress.fromParts(leader.host(), leader.port());\n                long startTimestamp = layoutHandle.getStartOffsetTimestamp();\n                long endTimestamp = layoutHandle.getEndOffsetTimestamp();\n\n                if (startTimestamp > endTimestamp) {\n                    throw new IllegalArgumentException(String.format(\"Invalid Kafka Offset start/end pair: %s - %s\", startTimestamp, endTimestamp));\n                }\n\n                TopicPartition topicPartition = new TopicPartition(partition.topic(), partition.partition());\n                consumer.assign(ImmutableList.of(topicPartition));\n\n                long beginningOffset = (startTimestamp == 0) ?\n                        consumer.beginningOffsets(ImmutableList.of(topicPartition)).values().iterator().next() :\n                        findOffsetsByTimestamp(consumer, topicPartition, startTimestamp);\n                long endOffset = (endTimestamp == 0) ?\n                        consumer.endOffsets(ImmutableList.of(topicPartition)).values().iterator().next() :\n                        findOffsetsByTimestamp(consumer, topicPartition, endTimestamp);\n\n                KafkaSplit split = new KafkaSplit(\n                        connectorId,\n                        topic,\n                        kafkaTableHandle.getKeyDataFormat(),\n                        kafkaTableHandle.getMessageDataFormat(),\n                        kafkaTableHandle.getKeyDataSchemaLocation().map(KafkaSplitManager::readSchema),","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-kafka/src/main/java/com/facebook/presto/kafka/KafkaSplitManager.java#L91-L127","documentation":"getSplits validates the timestamp bounds from the KafkaTableLayoutHandle: if startTimestamp > endTimestamp it throws an IllegalArgumentException 'Invalid Kafka Offset start/end pair'. These timestamps translate to offsets via offsetsForTimes, so an inverted range is a caller/config error, not a Kafka failure.","triggerScenarios":"A Kafka table layout was created with start-offset-timestamp greater than end-offset-timestamp (e.g. via a table property or session-level time-range constraint) and then getSplits runs a query on that table.","commonSituations":"Swapped start/end values in CREATE TABLE properties; a UI or scheduler passing (end, start) in the wrong order; timezone/unit confusion producing end < start.","solutions":["Fix the table's start-offset-timestamp/end-offset-timestamp properties so start <= end","Correct the ordering of the values supplied by the calling tool/job","Drop and recreate the table description with valid timestamp bounds"],"exampleFix":"// before\n\"startOffsetTimestamp\": 1700000000000,\n\"endOffsetTimestamp\": 1600000000000\n// after\n\"startOffsetTimestamp\": 1600000000000,\n\"endOffsetTimestamp\": 1700000000000","handlingStrategy":"validation","validationCode":"if (startOffsetTimestamp > endOffsetTimestamp)\n    throw new IllegalArgumentException(\"start must be <= end\");","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Validate start/end timestamp ordering in table DDL tooling","Use named constants/variables to avoid swapping arguments","Document that timestamps are epoch milliseconds"],"tags":["kafka","configuration","timestamps","validation","presto-connector"],"backgroundTag":"invalid-range-offset","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}