aloyszhang commented on issue #11013: URL: https://github.com/apache/pulsar/issues/11013#issuecomment-867684484
@BewareMyPower @hangc0276 This is problem happends when broker entry metadata is enabled without `AppendBrokerTimestampMetadataInterceptor`. Let's see the logic of expire message ```java try { msg = MessageImpl.deserializeBrokerEntryMetaDataFirst(entry.getDataBuffer()); return msg.isExpired(messageTTLInSeconds); } catch (Exception e) { log.error("[{}][{}] Error deserializing message for expiry check", topicName, subName, e); } ``` we will get an entry and get the `brokerEntryTimestamp` or the `publishTime` to compare with the message-ttl. And if broker entry metadata is enabled without `AppendBrokerTimestampMetadataInterceptor`. After`MessageImpl.deserializeBrokerEntryMetaDataFirst()` ```java msg.brokerEntryMetadata = Commands.parseBrokerEntryMetadataIfExist(headersAndPayloadWithBrokerEntryMetadata); if (msg.brokerEntryMetadata != null ) { msg.msgMetadata.clear(); msg.payload = null; msg.messageId = null; msg.topic = null; msg.cnx = null; msg.properties = Collections.emptyMap(); return msg; } ``` we will get a `MessageImpl`, this `MessageImpl` has brokerEntryMetadata but does not have `brokerTimestamp` and this `MessageImpl` has no `msgMetadata` since this field has been cleared which mean we can't get the `publish_time`. At last, when checking expiry, ```java public boolean isExpired(int messageTTLInSeconds) { return messageTTLInSeconds != 0 && (brokerEntryMetadata == null || !brokerEntryMetadata.hasBrokerTimestamp() ? (System.currentTimeMillis() > getPublishTime() + TimeUnit.SECONDS.toMillis(messageTTLInSeconds)) : (System.currentTimeMillis() > brokerEntryMetadata.getBrokerTimestamp() + TimeUnit.SECONDS.toMillis(messageTTLInSeconds))); } ``` broker will throw `java.lang.IllegalStateException: Field 'publish_time' is not set`. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org