# JDBC Input based on timestamp, concern regarding omitting an event

**URL:** <https://discuss.elastic.co/t/jdbc-input-based-on-timestamp-concern-regarding-omitting-an-event/175349>\
**Category:** Logstash\
**Created:** [April 4, 2019, 8:14am UTC](https://discuss.elastic.co/t/jdbc-input-based-on-timestamp-concern-regarding-omitting-an-event/175349 "2019-04-04T08:14:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![saif3r](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@saif3r](https://discuss.elastic.co/u/saif3r)\
**Post date:** [April 4, 2019, 8:14am UTC](https://discuss.elastic.co/t/jdbc-input-based-on-timestamp-concern-regarding-omitting-an-event/175349/1 "2019-04-04T08:14:51Z")

</div>

Hi Guys,  
I'm currently looking into JDBC Input plugin for Oracle and I have one concern. Assuming my pipeline is timestamp based with the following format: yyyy-mm-dd hh:mm:ss. Let's say that there are two event that occurred at the same time and Logstash run was started at the exact same time when those two events occured. So the timeline woud look like this:

2019-04-04 09:40:02 -\> DB entry 1  
2019-04-04 09:40:02 -\> Logstash starts  
2019-04-04 09:40:02 -\> DB entry 2  
2019-04-04 09:40:05 -\> DB entry 3  
2019-04-04 09:40:06 -\> Logstash starts

Since my pipeline is timestamp based, i have the following config snippet:  
`where timestamp > :sql_last_value`

I assume that after first Logstash run at 2019-04-04 09:40:02 .logstash\_jdbc\_last\_run will contain 2019-04-04 09:40:02 and store it as a reference. It means that second Logstash run will have the following where statement: `where timestamp > 2019-04-04 09:40:02`.  
Does this mean that DB entry 2 will be omitted entirely by Logstash? Is that possible? Is there a time offset or a buffer that makes Logstash 'wait' few seconds to make sure that no such situation will happen?

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [April 4, 2019, 12:17pm UTC](https://discuss.elastic.co/t/jdbc-input-based-on-timestamp-concern-regarding-omitting-an-event/175349/2 "2019-04-04T12:17:14Z")

</div>

My understanding is that there is always the possibility of missing rows when you use a time-based state. A sequence-based state should result in complete data.

---

<div class="post-metadata">

**Author:** ![saif3r](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@saif3r](https://discuss.elastic.co/u/saif3r)\
**Post date:** [April 4, 2019, 12:19pm UTC](https://discuss.elastic.co/t/jdbc-input-based-on-timestamp-concern-regarding-omitting-an-event/175349/3 "2019-04-04T12:19:12Z")

</div>

The issue is there's no sequential value I could use. Timestamp is the only column that might used as a reference.

---

<div class="post-metadata">

**Author:** ![guyboertje](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/guyboertje/32/31592_2.png) [@guyboertje](https://discuss.elastic.co/u/guyboertje)\
**Post date:** [April 4, 2019, 12:35pm UTC](https://discuss.elastic.co/t/jdbc-input-based-on-timestamp-concern-regarding-omitting-an-event/175349/4 "2019-04-04T12:35:49Z")

</div>

You need to be mindful of the UI representation of the timestamp value and the internal representation of that value.

Logstash should use the internal representation when creating the TIMESTAMP literal to inject into the statement (where `:sql\_last\_value is substituted)

The value received in the recordset before conversion should be a Java SQL Timestamp object created by the JDBC driver for the DB technology in use. This Java SQL Timestamp is converted to a Logstash Timestamp object instance with millisecond precision. I say should be, because it will as long as the column data type is a Timestamp.

For Oracle  
[https://docs.oracle.com/cd/B19306\_01/java.102/b14188/datamap.htm](https://docs.oracle.com/cd/B19306_01/java.102/b14188/datamap.htm)  
[https://docs.oracle.com/cd/B19306\_01/server.102/b14225/ch4datetime.htm#i1006050](https://docs.oracle.com/cd/B19306_01/server.102/b14225/ch4datetime.htm#i1006050)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 2, 2019, 12:38pm UTC](https://discuss.elastic.co/t/jdbc-input-based-on-timestamp-concern-regarding-omitting-an-event/175349/5 "2019-05-02T12:38:07Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
