diff --git a/src/main/java/io/github/hectorvent/floci/services/dynamodb/model/GlobalSecondaryIndex.java b/src/main/java/io/github/hectorvent/floci/services/dynamodb/model/GlobalSecondaryIndex.java
index 40c66a7218..5cd7e1e268 100644
--- a/src/main/java/io/github/hectorvent/floci/services/dynamodb/model/GlobalSecondaryIndex.java
+++ b/src/main/java/io/github/hectorvent/floci/services/dynamodb/model/GlobalSecondaryIndex.java
@@ -1,5 +1,6 @@
package io.github.hectorvent.floci.services.dynamodb.model;
+import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.quarkus.runtime.annotations.RegisterForReflection;
@@ -82,7 +83,13 @@ public class GlobalSecondaryIndex {
/**
* Returns all sort key attribute names in key-schema order. For a composite sort key this
* contains more than one element; ordering must consider all of them, not just the first.
+ *
+ *
{@code @JsonIgnore}d: it is derived from {@code keySchema} (redundant with
+ * {@link #getSortKeyName()}), and without a backing setter Jackson's getter-as-setter
+ * fallback tries to append into the immutable list this method returns, throwing
+ * {@code UnsupportedOperationException} on deserialization whenever the index has a sort key.
*/
+ @JsonIgnore
public List getSortKeyNames() {
return keySchema.stream()
.filter(k -> "RANGE".equals(k.getKeyType()))
diff --git a/src/main/java/io/github/hectorvent/floci/services/dynamodb/model/LocalSecondaryIndex.java b/src/main/java/io/github/hectorvent/floci/services/dynamodb/model/LocalSecondaryIndex.java
index 3050c6011d..d9d71483ef 100644
--- a/src/main/java/io/github/hectorvent/floci/services/dynamodb/model/LocalSecondaryIndex.java
+++ b/src/main/java/io/github/hectorvent/floci/services/dynamodb/model/LocalSecondaryIndex.java
@@ -1,5 +1,6 @@
package io.github.hectorvent.floci.services.dynamodb.model;
+import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.quarkus.runtime.annotations.RegisterForReflection;
@@ -81,7 +82,13 @@ public class LocalSecondaryIndex {
/**
* Returns all sort key attribute names in key-schema order. For a composite sort key this
* contains more than one element; ordering must consider all of them, not just the first.
+ *
+ * {@code @JsonIgnore}d: it is derived from {@code keySchema} (redundant with
+ * {@link #getSortKeyName()}), and without a backing setter Jackson's getter-as-setter
+ * fallback tries to append into the immutable list this method returns, throwing
+ * {@code UnsupportedOperationException} on deserialization whenever the index has a sort key.
*/
+ @JsonIgnore
public List getSortKeyNames() {
return keySchema.stream()
.filter(k -> "RANGE".equals(k.getKeyType()))
diff --git a/src/main/java/io/github/hectorvent/floci/services/dynamodb/model/TableDefinition.java b/src/main/java/io/github/hectorvent/floci/services/dynamodb/model/TableDefinition.java
index c1189c559e..c60e0ab4d0 100644
--- a/src/main/java/io/github/hectorvent/floci/services/dynamodb/model/TableDefinition.java
+++ b/src/main/java/io/github/hectorvent/floci/services/dynamodb/model/TableDefinition.java
@@ -1,5 +1,6 @@
package io.github.hectorvent.floci.services.dynamodb.model;
+import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.github.hectorvent.floci.core.common.AwsArnUtils;
import io.quarkus.runtime.annotations.RegisterForReflection;
@@ -226,7 +227,13 @@ public class TableDefinition {
/**
* Returns all sort key attribute names in key-schema order. For a composite sort key this
* contains more than one element; ordering must consider all of them, not just the first.
+ *
+ * {@code @JsonIgnore}d: it is derived from {@code keySchema} (redundant with
+ * {@link #getSortKeyName()}), and without a backing setter Jackson's getter-as-setter
+ * fallback tries to append into the immutable list this method returns, throwing
+ * {@code UnsupportedOperationException} on deserialization whenever the table has a sort key.
*/
+ @JsonIgnore
public List getSortKeyNames() {
return keySchema.stream()
.filter(k -> "RANGE".equals(k.getKeyType()))
diff --git a/src/test/java/io/github/hectorvent/floci/services/dynamodb/DynamoDbGsiSortKeyRestartTest.java b/src/test/java/io/github/hectorvent/floci/services/dynamodb/DynamoDbGsiSortKeyRestartTest.java
new file mode 100644
index 0000000000..84486b2a33
--- /dev/null
+++ b/src/test/java/io/github/hectorvent/floci/services/dynamodb/DynamoDbGsiSortKeyRestartTest.java
@@ -0,0 +1,99 @@
+package io.github.hectorvent.floci.services.dynamodb;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import io.github.hectorvent.floci.core.common.RegionResolver;
+import io.github.hectorvent.floci.core.storage.PersistentStorage;
+import io.github.hectorvent.floci.core.storage.StorageBackend;
+import io.github.hectorvent.floci.services.dynamodb.model.TableDefinition;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+
+import java.nio.file.Path;
+import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * Wire-protocol reproduction for floci-io/floci#2415: a table whose GSI (or LSI, or own primary
+ * key) has a RANGE key must survive a restart. Before the fix, {@code TableDefinition}'s Jackson
+ * round-trip threw on any such table; {@code PersistentStorage.load()} swallows that as an IOException,
+ * quarantines the file, and comes back up with zero tables in the whole store, not just the
+ * offending one.
+ *
+ * The GSI case here matches the issue's own reproduction (base table HASH-only, GSI with a
+ * HASH+RANGE key schema). The LSI and base-table-composite-key cases share the identical root
+ * cause (getSortKeyNames() added to all three model classes together in #2114) and are covered at
+ * the model level by {@code SortKeyNamesJacksonRoundTripTest}.
+ */
+class DynamoDbGsiSortKeyRestartTest {
+
+ private static final String TABLE = "con-gsi";
+ private static final String REGION = "us-east-1";
+
+ private final ObjectMapper mapper = new ObjectMapper();
+
+ /** A store backed by a real file, so a "restart" is just reading it again. */
+ private StorageBackend diskStore(Path file) {
+ PersistentStorage store =
+ new PersistentStorage<>(file, new TypeReference