Skip to content

SegmentAllocateAction (fixes #1515)#1896

Merged
fjy merged 2 commits intoapache:masterfrom
gianm:allocate-segment
Nov 19, 2015
Merged

SegmentAllocateAction (fixes #1515)#1896
fjy merged 2 commits intoapache:masterfrom
gianm:allocate-segment

Conversation

@gianm
Copy link
Copy Markdown
Contributor

@gianm gianm commented Oct 30, 2015

This is a feature meant to allow realtime tasks to work without being told upfront
what shardSpec they should use (so we can potentially publish a variable number
of segments per interval).

The idea is that there is a "pendingSegments" table in the metadata store that
tracks allocated segments. Each one has a segment id (the same segment id we know
and love) and is also part of a sequence.

The sequences are an idea from @cheddar that offers a way of doing replication.
If there are N tasks reading exactly the same data with exactly the same logic
(think Kafka tasks reading a fixed range of offsets) then you can place them
in the same sequence, and they will generate the same sequence of segments.

@gianm gianm closed this Oct 31, 2015
@gianm gianm reopened this Oct 31, 2015
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/pendingSegmentTable/pendingSegmentsTable just for consistency

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, this looks like a typo

@himanshug
Copy link
Copy Markdown
Contributor

say a task T allocates a new segment and hands it off, then it receives another event in the same interval. This time, task is supposed to use the "previousId" so that a new segment gets allocated. For this, is task supposed to retain a list of all the segments it has handed off in its lifetime? What happens if/when task is restored (do we keep that list maintained on disk as well) ?

@gianm
Copy link
Copy Markdown
Contributor Author

gianm commented Nov 3, 2015

@himanshug it needs to remember the last segment that has been allocated in its sequence (last overall, not last per interval, so just one segment).

@gianm gianm force-pushed the allocate-segment branch 2 times, most recently from 6a5f119 to 07996e6 Compare November 3, 2015 22:29
@gianm
Copy link
Copy Markdown
Contributor Author

gianm commented Nov 3, 2015

bad merge from master, will fix shortly.

@himanshug
Copy link
Copy Markdown
Contributor

@gianm I'm not sure how following case works.
say T1 and T2 are replicated tasks (with same group id)
T1 receives event e, allocates a segment-id for same and hands it off at some point
T2 is slow and now receives event e, will it get a new segment-id and hand it off successfully resulting in duplication of data?

@himanshug
Copy link
Copy Markdown
Contributor

@gianm trying to ans my own question. I guess T2 will receive same segment-id that T1 "created" and will eventually try to hand-off the same segment but will fail because commit metadata wouldn't match.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: this assumes, tasks in different replication set "share" the lock so that they both will be able to get lock on same interval if they received events with same or close enough timestamp.

@gianm gianm force-pushed the allocate-segment branch 2 times, most recently from f604300 to 6ad58ff Compare November 9, 2015 15:59
@gianm
Copy link
Copy Markdown
Contributor Author

gianm commented Nov 9, 2015

@himanshug yes, that's what would happen, T1/T2 get the same segment id because they see the same events in the same order, and they're allocating ids from the same sequence.

IMO in that case the slow task shouldn't fail- it should realize that the faster task handed off that segment first (based on inspection of the commit metadata when its attempt to commit fails) and either keep continuing on or skip forwards.

@gianm
Copy link
Copy Markdown
Contributor Author

gianm commented Nov 9, 2015

Tests run: 7, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 600.39 sec <<< FAILURE! - in io.druid.server.namespace.cache.NamespaceExtractionCacheManagerExecutorsTest
testConcurrentAddDelete(io.druid.server.namespace.cache.NamespaceExtractionCacheManagerExecutorsTest)  Time elapsed: 600.007 sec  <<< ERROR!
java.lang.Exception: test timed out after 600000 milliseconds
    at sun.misc.Unsafe.park(Native Method)
    at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
    at java.util.concurrent.FutureTask.awaitDone(FutureTask.java:429)
    at java.util.concurrent.FutureTask.get(FutureTask.java:191)
    at io.druid.server.namespace.cache.NamespaceExtractionCacheManagerExecutorsTest.testConcurrentAddDelete(NamespaceExtractionCacheManagerExecutorsTest.java:312)

@gianm gianm closed this Nov 9, 2015
@gianm gianm reopened this Nov 9, 2015
@gianm gianm closed this Nov 11, 2015
@gianm gianm reopened this Nov 11, 2015
This is a feature meant to allow realtime tasks to work without being told upfront
what shardSpec they should use (so we can potentially publish a variable number
of segments per interval).

The idea is that there is a "pendingSegments" table in the metadata store that
tracks allocated segments. Each one has a segment id (the same segment id we know
and love) and is also part of a sequence.

The sequences are an idea from @cheddar that offers a way of doing replication.
If there are N tasks reading exactly the same data with exactly the same logic
(think Kafka tasks reading a fixed range of offsets) then you can place them
in the same sequence, and they will generate the same sequence of segments.
@himanshug
Copy link
Copy Markdown
Contributor

👍

@fjy fjy closed this Nov 18, 2015
@fjy fjy reopened this Nov 18, 2015
@fjy
Copy link
Copy Markdown
Contributor

fjy commented Nov 18, 2015

👍

fjy added a commit that referenced this pull request Nov 19, 2015
@fjy fjy merged commit 21c84b5 into apache:master Nov 19, 2015
@fjy fjy modified the milestone: 0.9.0 Feb 4, 2016
return e != null && (e instanceof SQLTransientException
|| e instanceof SQLRecoverableException
|| e instanceof UnableToObtainConnectionException
|| e instanceof UnableToExecuteStatementException
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gianm this causes lots of retries for duplicate primary key entry errors that will never be transient unless someone manually cleans the DB

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#2573 should fix this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants