You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@phoenix.apache.org by jfernandosf <gi...@git.apache.org> on 2014/07/18 00:20:40 UTC
[GitHub] phoenix pull request: PHOENIX-1096 Fix for concurreny bug caused b...
GitHub user jfernandosf opened a pull request:
https://github.com/apache/phoenix/pull/4
PHOENIX-1096 Fix for concurreny bug caused by a cached SequenceExpression using the same byte[] buffer in multiple threads
This is a fix for the Upsert...Select issue we ran into when using Sequences in the SELECT portion of the statement. We were generating mutations with identical row keys because multiple rows were being assigned the same sequence number. I tracked this down to the fact that we cache SequenceExpression and have a member field byte[] where we store the sequence after reading it. This buffer was being written to by multiple threads and so there was no guarantee a thread would see the sequence it read and based on timing multiple threads would read the same sequence when generating the row key for the mutation.
Moving the buffer to a local variable addresses this issue.
I have also included a test that Samarth and I created to repro the issue that is now passing.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/jfernandosf/phoenix 3.0
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/phoenix/pull/4.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #4
----
commit dad771fa7be4320a20fb508a495c6478dcca53f6
Author: Jan Fernando <jf...@salesforce.com>
Date: 2014-07-17T21:35:00Z
Fix for concurreny bug caused by a cached SequenceExpression using the same byte[] buffer in multiple threads to store sequence values by multiple threads when processing upsert...select result sets
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] phoenix pull request: PHOENIX-1096 Fix for concurreny bug caused b...
Posted by JamesRTaylor <gi...@git.apache.org>.
Github user JamesRTaylor commented on the pull request:
https://github.com/apache/phoenix/pull/4#issuecomment-49374984
Nice work, @jfernandosf. Would you mind attaching a .patch file to the JIRA for 3.0, 4.0, and master (if they're different)?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] phoenix pull request: PHOENIX-1096 Fix for concurreny bug caused b...
Posted by jfernandosf <gi...@git.apache.org>.
Github user jfernandosf commented on a diff in the pull request:
https://github.com/apache/phoenix/pull/4#discussion_r15088076
--- Diff: phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertSelectIT.java ---
@@ -39,18 +39,36 @@
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
+import java.util.Map;
import java.util.Properties;
import org.apache.phoenix.query.QueryConstants;
+import org.apache.phoenix.query.QueryServices;
import org.apache.phoenix.schema.PDataType;
import org.apache.phoenix.util.PhoenixRuntime;
import org.apache.phoenix.util.QueryUtil;
+import org.apache.phoenix.util.ReadOnlyProps;
import org.apache.phoenix.util.TestUtil;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
+import com.google.common.collect.Maps;
+
@Category(ClientManagedTimeTest.class)
public class UpsertSelectIT extends BaseClientManagedTimeIT {
+
+
+ @BeforeClass
+ @Shadower(classBeingShadowed = BaseClientManagedTimeIT.class)
+ public static void doSetup() throws Exception {
--- End diff --
In order to reliably repro this issue we needed a higher level of concurrency that the defaults and there we need to override the default thread pool size to 64 so we can have 64 salt buckets.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---