Skip to content

android.database.sqlite.SQLiteConstraintException: UNIQUE constraint failed: ParseObjects.className, ParseObjects.objectId (code 2067) #218

@alexblack

Description

@alexblack

It looks like after I implemented a retry work around for the failing to save parse installation bug I might have hit a new bug?

My retry code looks like this:

 // Initialize the parse installation
            return parseInit.initParseInstallation().continueWithTask(new Continuation<ParseInstallation, Task<ParseInstallation>>() {
              @Override
              public Task<ParseInstallation> then(Task<ParseInstallation> task) throws Exception {
                if (task.isFaulted()) {
                  // Retry once, try to work around bug that causes '135 deviceType not specified' errors
                  // https://github.com/ParsePlatform/Parse-SDK-Android/issues/203#issuecomment-150045761
                  return parseInit.initParseInstallation().onSuccess(new Continuation<ParseInstallation, ParseInstallation>() {
                    @Override
                    public ParseInstallation then(Task<ParseInstallation> task) throws Exception {
                      App.logEvent(App.this, "parse-installation", "retry-success", task.getResult().getObjectId());
                      return task.getResult();
                    }
                  }, executor);
                } else {
                  return task;
                }
              }
            }, executor);

With initParseInstallation:

  public Task<ParseInstallation> initParseInstallation() {
    final TimingLogger timings = new TimingLogger(TAG, "initParseInstallation");
    Log.d(TAG, "initParseInstallation");
    try {
      final ParseInstallation installation = ParseInstallation.getCurrentInstallation();
      installation.put("flavor", BuildConfig.FLAVOR);
      installation.put("accountId", accountId);
      installation.put("user", ParseUser.getCurrentUser());
      try {
        installation.put("androidId", Settings.Secure.getString(ctx.getContentResolver(), Settings.Secure.ANDROID_ID));
        installation.put("android", String.format("%s (%s %s)", Build.VERSION.RELEASE, Build.VERSION.CODENAME, Build.VERSION.INCREMENTAL));
        installation.put("device", String.format("%s (%s)", DeviceUtils.getDeviceName(), Build.HARDWARE));
        installation.put("abi", Build.CPU_ABI);
        installation.put("syncEnabled", Syncer.syncEnabled(ctx));
        installation.increment("appStart");
      } catch (Exception e) {
        App.err(ctx, "Failed to set properties on installation", e);
      }

      if (installation.containsKey("GCMSenderId"))
        installation.remove("GCMSenderId");

      timings.addSplit("setInstall");

      return installation.saveInBackground().continueWithTask(new Continuation<Void, Task<ParseInstallation>>() {
        @Override
        public Task<ParseInstallation> then(Task<Void> task) throws Exception {
          timings.addSplit("onInstall");
          if (task.isFaulted()) {
            if (task.getError() instanceof ParseException) {
              ParseException e = (ParseException) task.getError();
              App.err(ctx, "Failed to save parse installation: " + e.getCode(), new Exception(e));
            } else {
              App.err(ctx, "Failed to save parse installation", new Exception(task.getError()));
            }
            return Task.forError(task.getError());
          } else {
            Log.d(TAG, "Successfully initialized parseInstallation: " + installation.getObjectId());
            return Task.forResult(installation);
          }
        }
      });
    } catch (Exception e) {
      App.err(ctx, "Failed to setup parse installation", e);
      return Task.forError(e);
    }
  }
Non-fatal Exception: java.lang.Exception: android.database.sqlite.SQLiteConstraintException: UNIQUE constraint failed: ParseObjects.className, ParseObjects.objectId (code 2067)
       at com.aadhk.woinvoice.util.ParseInit$2.then(ProGuard)
       at com.aadhk.woinvoice.util.ParseInit$2.then(ProGuard)
       at bolts.Task$15.run(ProGuard)
       at bolts.BoltsExecutors$ImmediateExecutor.execute(ProGuard)
       at bolts.Task.completeAfterTask(ProGuard)
       at bolts.Task.access$200(ProGuard)
       at bolts.Task$11.then(ProGuard)
       at bolts.Task$11.then(ProGuard)
       at bolts.Task.runContinuations(ProGuard)
       at bolts.Task.access$600(ProGuard)
       at bolts.Task$TaskCompletionSource.trySetError(ProGuard)
       at bolts.Task$TaskCompletionSource.setError(ProGuard)
       at bolts.Task$15$1.then(ProGuard)
       at bolts.Task$15$1.then(ProGuard)
       at bolts.Task$14.run(ProGuard)
       at bolts.BoltsExecutors$ImmediateExecutor.execute(ProGuard)
       at bolts.Task.completeImmediately(ProGuard)
       at bolts.Task.access$100(ProGuard)
       at bolts.Task$10.then(ProGuard)
       at bolts.Task$10.then(ProGuard)
       at bolts.Task.runContinuations(ProGuard)
       at bolts.Task.access$600(ProGuard)
       at bolts.Task$TaskCompletionSource.trySetError(ProGuard)
       at bolts.Task$TaskCompletionSource.setError(ProGuard)
       at bolts.Task$15$1.then(ProGuard)
       at bolts.Task$15$1.then(ProGuard)
       at bolts.Task$14.run(ProGuard)
       at bolts.BoltsExecutors$ImmediateExecutor.execute(ProGuard)
       at bolts.Task.completeImmediately(ProGuard)
       at bolts.Task.access$100(ProGuard)
       at bolts.Task$10.then(ProGuard)
       at bolts.Task$10.then(ProGuard)
       at bolts.Task.runContinuations(ProGuard)
       at bolts.Task.access$600(ProGuard)
       at bolts.Task$TaskCompletionSource.trySetError(ProGuard)
       at bolts.Task$TaskCompletionSource.setError(ProGuard)
       at bolts.Task$15$1.then(ProGuard)
       at bolts.Task$15$1.then(ProGuard)
       at bolts.Task$14.run(ProGuard)
       at bolts.BoltsExecutors$ImmediateExecutor.execute(ProGuard)
       at bolts.Task.completeImmediately(ProGuard)
       at bolts.Task.access$100(ProGuard)
       at bolts.Task$10.then(ProGuard)
       at bolts.Task$10.then(ProGuard)
       at bolts.Task.runContinuations(ProGuard)
       at bolts.Task.access$600(ProGuard)
       at bolts.Task$TaskCompletionSource.trySetError(ProGuard)
       at bolts.Task$TaskCompletionSource.setError(ProGuard)
       at bolts.Task$15$1.then(ProGuard)
       at bolts.Task$15$1.then(ProGuard)
       at bolts.Task$14.run(ProGuard)
       at bolts.BoltsExecutors$ImmediateExecutor.execute(ProGuard)
       at bolts.Task.completeImmediately(ProGuard)
       at bolts.Task.continueWith(ProGuard)
       at bolts.Task.continueWith(ProGuard)
       at bolts.Task$15.run(ProGuard)
       at bolts.BoltsExecutors$ImmediateExecutor.execute(ProGuard)
       at bolts.Task.completeAfterTask(ProGuard)
       at bolts.Task.access$200(ProGuard)
       at bolts.Task$11.then(ProGuard)
       at bolts.Task$11.then(ProGuard)
       at bolts.Task.runContinuations(ProGuard)
       at bolts.Task.access$600(ProGuard)
       at bolts.Task$TaskCompletionSource.trySetError(ProGuard)
       at bolts.Task$TaskCompletionSource.setError(ProGuard)
       at bolts.Task$15$1.then(ProGuard)
       at bolts.Task$15$1.then(ProGuard)
       at bolts.Task$14.run(ProGuard)
       at bolts.BoltsExecutors$ImmediateExecutor.execute(ProGuard)
       at bolts.Task.completeImmediately(ProGuard)
       at bolts.Task.access$100(ProGuard)
       at bolts.Task$10.then(ProGuard)
       at bolts.Task$10.then(ProGuard)
       at bolts.Task.runContinuations(ProGuard)
       at bolts.Task.access$600(ProGuard)
       at bolts.Task$TaskCompletionSource.trySetError(ProGuard)
       at bolts.Task$TaskCompletionSource.setError(ProGuard)
       at bolts.Task$15$1.then(ProGuard)
       at bolts.Task$15$1.then(ProGuard)
       at bolts.Task$14.run(ProGuard)
       at bolts.BoltsExecutors$ImmediateExecutor.execute(ProGuard)
       at bolts.Task.completeImmediately(ProGuard)
       at bolts.Task.access$100(ProGuard)
       at bolts.Task$10.then(ProGuard)
       at bolts.Task$10.then(ProGuard)
       at bolts.Task.runContinuations(ProGuard)
       at bolts.Task.access$600(ProGuard)
       at bolts.Task$TaskCompletionSource.trySetError(ProGuard)
       at bolts.Task$TaskCompletionSource.setError(ProGuard)
       at bolts.Task$15$1.then(ProGuard)
       at bolts.Task$15$1.then(ProGuard)
       at bolts.Task$14.run(ProGuard)
       at bolts.BoltsExecutors$ImmediateExecutor.execute(ProGuard)
       at bolts.Task.completeImmediately(ProGuard)
       at bolts.Task.continueWith(ProGuard)
       at bolts.Task.continueWith(ProGuard)
       at bolts.Task$15.run(ProGuard)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java)
       at java.lang.Thread.run(Thread.java)
Caused by android.database.sqlite.SQLiteConstraintException: UNIQUE constraint failed: ParseObjects.className, ParseObjects.objectId (code 2067)
       at android.database.sqlite.SQLiteConnection.nativeExecuteForChangedRowCount(SQLiteConnection.java)
       at android.database.sqlite.SQLiteConnection.executeForChangedRowCount(SQLiteConnection.java)
       at android.database.sqlite.SQLiteSession.executeForChangedRowCount(SQLiteSession.java)
       at android.database.sqlite.SQLiteStatement.executeUpdateDelete(SQLiteStatement.java)
       at android.database.sqlite.SQLiteDatabase.updateWithOnConflict(SQLiteDatabase.java)
       at android.database.sqlite.SQLiteDatabase.update(SQLiteDatabase.java)
       at com.parse.ParseSQLiteDatabase$22.then(ProGuard)
       at com.parse.ParseSQLiteDatabase$22.then(ProGuard)
       at bolts.Task$14.run(ProGuard)
       at bolts.BoltsExecutors$ImmediateExecutor.execute(ProGuard)
       at bolts.Task.completeImmediately(ProGuard)
       at bolts.Task.continueWith(ProGuard)
       at bolts.Task.continueWith(ProGuard)
       at bolts.Task$12.then(ProGuard)
       at bolts.Task$12.then(ProGuard)
       at bolts.Task$15.run(ProGuard)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java)
       at java.lang.Thread.run(Thread.java)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions